Class: HentryConsumer::HEntry

Inherits:
Element
  • Object
show all
Defined in:
lib/hentry_consumer/h_entry.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_h_card, #parse_h_entry, #parse_microformat, #symbolize_class, #to_html, #to_xml

Constructor Details

This class inherits a constructor from HentryConsumer::Element

Instance Attribute Details

#authorObject Also known as: authors

Returns the value of attribute author.



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

def author
  @author
end

#bookmarkObject

Returns the value of attribute bookmark.



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

def bookmark
  @bookmark
end

#categoriesObject

Returns the value of attribute categories.



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

def categories
  @categories
end

#contentObject

Returns the value of attribute content.



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

def content
  @content
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#published_atObject

Returns the value of attribute published_at.



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

def published_at
  @published_at
end

#summaryObject

Returns the value of attribute summary.



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

def summary
  @summary
end

Instance Method Details

#older_than(time) ⇒ Object



8
9
10
# File 'lib/hentry_consumer/h_entry.rb', line 8

def older_than(time)
  Time.parse(published_at.first) < time if time
end

#parse_dt_published(element) ⇒ Object



29
30
31
# File 'lib/hentry_consumer/h_entry.rb', line 29

def parse_dt_published(element)
  assign_value :published_at, element["datetime"]
end

#parse_e_content(element) ⇒ Object



25
26
27
# File 'lib/hentry_consumer/h_entry.rb', line 25

def parse_e_content(element)
  assign_value :content, element.inner_html
end

#parse_p_author(element) ⇒ Object



16
17
18
# File 'lib/hentry_consumer/h_entry.rb', line 16

def parse_p_author(element)
  assign_value :author, HCard.new(element.children)
end

#parse_p_category(element) ⇒ Object



20
21
22
23
# File 'lib/hentry_consumer/h_entry.rb', line 20

def parse_p_category(element)
  self.categories ||= {}
  self.categories[element.text.gsub("\n", " ").strip] = element["href"]
end

#parse_p_name(element) ⇒ Object



12
13
14
# File 'lib/hentry_consumer/h_entry.rb', line 12

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

#parse_p_summary(element) ⇒ Object



37
38
39
# File 'lib/hentry_consumer/h_entry.rb', line 37

def parse_p_summary(element)
  assign_value :summary, element.text
end

#parse_u_uid(element) ⇒ Object



33
34
35
# File 'lib/hentry_consumer/h_entry.rb', line 33

def parse_u_uid(element)
  assign_value :bookmark, element["href"]
end

#to_hashObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/hentry_consumer/h_entry.rb', line 41

def to_hash
  {
    :type => ["h-entry"],
    :properties => {
      :name         => self.name,
      :categories   => self.categories,
      :author       => self.author,
      :content      => self.content,
      :bookmark     => self.bookmark,
      :published_at => self.published_at,
      :summary      => self.summary
    }
  }
end

#to_json(*a) ⇒ Object



56
57
58
# File 'lib/hentry_consumer/h_entry.rb', line 56

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