Class: HentryConsumer::HCard

Inherits:
Element
  • Object
show all
Defined in:
lib/hentry_consumer/h_card.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#element, #items

Instance Method Summary collapse

Methods inherited from Element

#[], #[]=, #assign_value, #cleanse_classes, #initialize, #parse_element, #parse_elements, #parse_microformat, #to_html, #to_xml

Constructor Details

This class inherits a constructor from HentryConsumer::Element

Instance Attribute Details

#emailObject Also known as: emails

Returns the value of attribute email.



5
6
7
# File 'lib/hentry_consumer/h_card.rb', line 5

def email
  @email
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/hentry_consumer/h_card.rb', line 5

def name
  @name
end

#urlObject Also known as: urls

Returns the value of attribute url.



5
6
7
# File 'lib/hentry_consumer/h_card.rb', line 5

def url
  @url
end

Instance Method Details

#parse_p_name(element) ⇒ Object



9
10
11
# File 'lib/hentry_consumer/h_card.rb', line 9

def parse_p_name(element)
  assign_value :name, element.text
end

#parse_u_email(element) ⇒ Object



13
14
15
# File 'lib/hentry_consumer/h_card.rb', line 13

def parse_u_email(element)
  assign_value :email, element["href"]
end

#parse_u_url(element) ⇒ Object



17
18
19
# File 'lib/hentry_consumer/h_card.rb', line 17

def parse_u_url(element)
  assign_value :url, element["href"]
end

#to_hashObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/hentry_consumer/h_card.rb', line 21

def to_hash
  {
    :type => ["h-card"],
    :properties => {
      :name  => self.name,
      :email => self.email,
      :url   => self.url
    }
  }
end

#to_json(*a) ⇒ Object



32
33
34
# File 'lib/hentry_consumer/h_card.rb', line 32

def to_json(*a)
  to_hash.to_json(a)
end