Class: HTMLSchema::API::Attribute
Instance Attribute Summary
#options, #required, #type, #value
Attributes inherited from Object
#_name, #as, #attributes, #classes, #parent, #source, #types
Instance Method Summary
collapse
attribute?, #format, #initialize, #inspect, #to_object
Methods inherited from Object
#[], #attribute, #initialize, #inspect, #to_object, #type
Instance Method Details
#microdata ⇒ Object
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/html-schema/api/attribute.rb', line 4
def microdata
if @microdata.nil?
object = HTMLSchema.instance.microdata[parent]
object = object[_name] if object
object = false if object.blank?
@microdata = object
end
@microdata
end
|
#microdata? ⇒ Boolean
15
16
17
|
# File 'lib/html-schema/api/attribute.rb', line 15
def microdata?
!!microdata
end
|
19
20
21
22
23
24
25
26
27
|
# File 'lib/html-schema/api/attribute.rb', line 19
def microformat
if @microformat.nil?
object = HTMLSchema.instance.microformat[parent]
object = object[_name] if object
object = false if object.blank?
@microformat = object
end
@microformat
end
|
29
30
31
|
# File 'lib/html-schema/api/attribute.rb', line 29
def microformat?
!!microformat
end
|
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/html-schema/api/attribute.rb', line 41
def to_hash
if microdata? && microformat?
to_microdata.merge(to_microformat)
elsif microdata?
to_microdata
elsif microformat?
to_microformat
else
{}
end
end
|
#to_microdata ⇒ Object
33
34
35
|
# File 'lib/html-schema/api/attribute.rb', line 33
def to_microdata
microdata.to_hash
end
|
37
38
39
|
# File 'lib/html-schema/api/attribute.rb', line 37
def to_microformat
microformat.to_hash
end
|