Class: RDF::N3::Algebra::Time::Second
- Inherits:
- 
      ResourceOperator
      
        - Object
- SPARQL::Algebra::Operator::Binary
- ResourceOperator
- RDF::N3::Algebra::Time::Second
 
- Defined in:
- lib/rdf/n3/algebra/time/second.rb
Overview
For a date-time, its time:second is the seconds component.
Constant Summary collapse
Instance Attribute Summary
Attributes included from Enumerable
Instance Method Summary collapse
- 
  
    
      #resolve(resource, position:)  ⇒ RDF::Term 
    
    
  
  
  
  
  
  
  
  
  
    The time:second operator takes string or dateTime and extracts the seconds component. 
- 
  
    
      #valid?(subject, object)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    There is no second unless it was specified in the lexical form. 
Methods inherited from ResourceOperator
#as_literal, #execute, #input_operand
Methods included from Builtin
#each, #evaluate, #hash, #input_operand, #rank, #to_uri
Instance Method Details
#resolve(resource, position:) ⇒ RDF::Term
The time:second operator takes string or dateTime and extracts the seconds component.
| 17 18 19 20 21 22 23 24 25 26 | # File 'lib/rdf/n3/algebra/time/second.rb', line 17 def resolve(resource, position:) case position when :subject return nil unless resource.literal? RDF::Literal(resource.as_datetime.seconds.to_i) when :object return nil unless resource.literal? || resource.variable? resource end end | 
#valid?(subject, object) ⇒ Boolean
There is no second unless it was specified in the lexical form
| 30 31 32 | # File 'lib/rdf/n3/algebra/time/second.rb', line 30 def valid?(subject, object) subject.value.match?(%r(^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})) end |