class MicroMicro::Parsers::DateTimePropertyParser
Constants
- HTML_ATTRIBUTES_MAP
Public Instance Methods
value()
click to toggle source
@see microformats.org/wiki/microformats2-parsing#parsing_a_dt-_property
@return [String]
Calls superclass method
MicroMicro::Parsers::BasePropertyParser#value
# File lib/micro_micro/parsers/date_time_property_parser.rb, line 13 def value @value ||= resolved_value || attribute_value || super end
Private Instance Methods
adopted_date_time_parser()
click to toggle source
@see microformats.org/wiki/value-class-pattern#microformats2_parsers_implied_date
@return [MicroMicro::Parsers::DateTimeParser, nil]
# File lib/micro_micro/parsers/date_time_property_parser.rb, line 22 def adopted_date_time_parser @adopted_date_time_parser ||= begin date_time_siblings = (property.prev_all.reverse + property.next_all).select { |prop| prop.prefix == 'dt' } date_time_siblings.map { |prop| DateTimeParser.new(prop.value) }.find(&:normalized_date) end end
attribute_value()
click to toggle source
@return [String, nil]
# File lib/micro_micro/parsers/date_time_property_parser.rb, line 31 def attribute_value self.class.attribute_value_from(node, HTML_ATTRIBUTES_MAP) end
date_time_parser()
click to toggle source
@return [MicroMicro::Parsers::DateTimeParser]
# File lib/micro_micro/parsers/date_time_property_parser.rb, line 36 def date_time_parser @date_time_parser ||= DateTimeParser.new(ValueClassPatternParser.new(node, ' ').value) end
imply_date?()
click to toggle source
@see microformats.org/wiki/value-class-pattern#microformats2_parsers_implied_date
@return [Boolean]
# File lib/micro_micro/parsers/date_time_property_parser.rb, line 43 def imply_date? date_time_parser.normalized_time && !date_time_parser.normalized_date && adopted_date_time_parser end
resolved_value()
click to toggle source
@return [String]
# File lib/micro_micro/parsers/date_time_property_parser.rb, line 48 def resolved_value return "#{adopted_date_time_parser.normalized_date} #{date_time_parser.value}" if imply_date? date_time_parser.value end