Class: HTMLSchema::API::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/html-schema/api/object.rb

Instance Attribute Summary

Attributes inherited from Object

#_name, #as, #attributes, #classes, #parent, #source, #types

Instance Method Summary collapse

Methods inherited from Object

#[], #attribute, #initialize, #inspect, #type

Constructor Details

This class inherits a constructor from HTMLSchema::Object

Instance Method Details

#microdataObject



5
6
7
# File 'lib/html-schema/api/object.rb', line 5

def microdata
  @microdata ||= HTMLSchema.instance.microdata[_name]
end

#microformatObject



9
10
11
# File 'lib/html-schema/api/object.rb', line 9

def microformat
  @microformat ||= HTMLSchema.instance.microformat[_name]
end

#to_hashObject



13
14
15
16
17
18
# File 'lib/html-schema/api/object.rb', line 13

def to_hash
  result = {}
  deep_merge(result, microdata.to_hash) if microdata
  deep_merge(result, microformat.to_hash) if microformat
  result
end

#to_objectObject



20
21
22
23
24
25
# File 'lib/html-schema/api/object.rb', line 20

def to_object
  result = {}
  deep_merge(result, microdata.to_object) if microdata
  deep_merge(result, microformat.to_object) if microformat
  result
end