Class: Microformat::AttributeDefinition
- Inherits:
-
Object
- Object
- Microformat::AttributeDefinition
- Defined in:
- lib/microformat/attribute_definition.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #attribute(name, options = {}, &block) ⇒ Object
-
#initialize(&block) ⇒ AttributeDefinition
constructor
A new instance of AttributeDefinition.
- #map_to(document) ⇒ Object
Constructor Details
#initialize(&block) ⇒ AttributeDefinition
Returns a new instance of AttributeDefinition.
8 9 10 11 |
# File 'lib/microformat/attribute_definition.rb', line 8 def initialize(&block) @attributes ||= {} block.yield(self) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/microformat/attribute_definition.rb', line 6 def attributes @attributes end |
Instance Method Details
#attribute(name, options = {}, &block) ⇒ Object
13 14 15 16 17 |
# File 'lib/microformat/attribute_definition.rb', line 13 def attribute(name, = {}, &block) Attribute.new(name, , &block).tap do |attribute| @attributes.merge!(name.to_sym => attribute) end end |
#map_to(document) ⇒ Object
19 20 21 |
# File 'lib/microformat/attribute_definition.rb', line 19 def map_to(document) AttributeMap.new(self, document) end |