Module: HTMLSchema::DSL
- Included in:
- API, Microdata, Microformat
- Defined in:
- lib/html-schema/dsl.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #root ⇒ Object
- #to_hash ⇒ Object
- #type(name, options = {}, &block) ⇒ Object
- #types ⇒ Object
Instance Method Details
#[](key) ⇒ Object
15 16 17 |
# File 'lib/html-schema/dsl.rb', line 15 def [](key) types[key] end |
#[]=(key, value) ⇒ Object
19 20 21 |
# File 'lib/html-schema/dsl.rb', line 19 def []=(key, value) types[key] = value end |
#root ⇒ Object
11 12 13 |
# File 'lib/html-schema/dsl.rb', line 11 def root @root ||= types.values.first end |
#to_hash ⇒ Object
23 24 25 26 27 |
# File 'lib/html-schema/dsl.rb', line 23 def to_hash types.keys.inject({}) do |hash, key| hash[key] = types[key].to_hash end end |
#type(name, options = {}, &block) ⇒ Object
3 4 5 |
# File 'lib/html-schema/dsl.rb', line 3 def type(name, = {}, &block) types[name] = "#{self.name}::Object".constantize.new(name, , &block) end |
#types ⇒ Object
7 8 9 |
# File 'lib/html-schema/dsl.rb', line 7 def types @types ||= {} end |