Module: HTMLSchema::DSL

Included in:
API, Microdata, Microformat
Defined in:
lib/html-schema/dsl.rb

Instance Method Summary collapse

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

#rootObject



11
12
13
# File 'lib/html-schema/dsl.rb', line 11

def root
  @root ||= types.values.first
end

#to_hashObject



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, options = {}, &block)
  types[name] = "#{self.name}::Object".constantize.new(name, options, &block)
end

#typesObject



7
8
9
# File 'lib/html-schema/dsl.rb', line 7

def types
  @types ||= {}
end