organizing broke the world
This commit is contained in:
parent
113d95af17
commit
081d0e5000
15 changed files with 189 additions and 164 deletions
|
@ -1,6 +1,6 @@
|
|||
module Microformats2
|
||||
module Property
|
||||
class DateTime < Property::Parser
|
||||
class DateTime < Foundation
|
||||
def value
|
||||
::DateTime.parse(super)
|
||||
rescue ArgumentError => e
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Microformats2
|
||||
module Property
|
||||
class Embedded < Property::Parser
|
||||
class Embedded < Foundation
|
||||
def value
|
||||
@value ||= @element.inner_html.strip
|
||||
end
|
||||
|
|
|
@ -1,22 +1,25 @@
|
|||
module Microformats2
|
||||
module Property
|
||||
class Parser < Microformats2::Parser
|
||||
attr_accessor :value, :element
|
||||
class Foundation
|
||||
attr_accessor :element, :value, :formats
|
||||
|
||||
def initialize(element)
|
||||
@element = element
|
||||
super()
|
||||
@formats = []
|
||||
end
|
||||
|
||||
def parse
|
||||
html_classes = element.attribute("class").to_s.split
|
||||
format_classes = html_classes.select { |html_class| html_class =~ /^(h-)/ }
|
||||
if format_classes.length >= 1
|
||||
parse_microformat(element, format_classes)
|
||||
end
|
||||
self
|
||||
formats << FormatParser.parse(element) if format_classes.length >=1
|
||||
value
|
||||
self
|
||||
end
|
||||
|
||||
def format_classes
|
||||
element.attribute("class").to_s.split.select do |html_class|
|
||||
html_class =~ Format::CLASS_REG_EXP
|
||||
end
|
||||
end
|
||||
|
||||
def value
|
||||
@value ||= value_class_pattern || element_value || text_value
|
||||
end
|
||||
|
@ -45,7 +48,7 @@ module Microformats2
|
|||
if formats.empty?
|
||||
value.to_s
|
||||
else
|
||||
{ value: value.to_s }.merge formats.first.to_hash
|
||||
{ value: value.to_s }.merge(formats.first.to_hash)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
module Microformats2
|
||||
module Property
|
||||
class Text < Property::Parser
|
||||
class Text < Foundation
|
||||
def attr_map
|
||||
@attr_map = {
|
||||
"abbr" => "title",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Microformats2
|
||||
module Property
|
||||
class Url < Property::Parser
|
||||
class Url < Foundation
|
||||
def attr_map
|
||||
@attr_map = {
|
||||
"a" => "href",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue