Class: Microformat::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/microformat/format.rb

Direct Known Subclasses

Card, Review, ReviewAggregate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ Format

Returns a new instance of Format.



22
23
24
# File 'lib/microformat/format.rb', line 22

def initialize(document)
  @document = document
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/microformat/format.rb', line 30

def method_missing(name)
  if attribute_map.respond_to?(name)
    attribute_map.send(name)
  else
    super(name)
  end
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



20
21
22
# File 'lib/microformat/format.rb', line 20

def document
  @document
end

Class Method Details

.attribute_definition(&block) ⇒ Object



11
12
13
14
# File 'lib/microformat/format.rb', line 11

def self.attribute_definition(&block)
  @attribute_definition = AttributeDefinition.new(&block) if block_given?
  @attribute_definition
end

.parse(document) ⇒ Object



16
17
18
# File 'lib/microformat/format.rb', line 16

def self.parse(document)
  new(document)
end

.selector(selector = nil) ⇒ Object



6
7
8
9
# File 'lib/microformat/format.rb', line 6

def self.selector(selector = nil)
  define_selector(selector) if selector
  @selector
end

Instance Method Details

#respond_to_missing?(name, public_only = false) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/microformat/format.rb', line 26

def respond_to_missing?(name, public_only = false)
  attribute_map.respond_to?(name)
end