Class: Greedy::Entry
- Inherits:
-
Object
- Object
- Greedy::Entry
- Defined in:
- lib/greedy/entry.rb
Defined Under Namespace
Modules: States
Constant Summary collapse
- DEFAULT_CHAR_COUNT =
2000
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#feed ⇒ Object
readonly
Returns the value of attribute feed.
-
#google_item_id ⇒ Object
readonly
Returns the value of attribute google_item_id.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#truncated_body ⇒ Object
readonly
Returns the value of attribute truncated_body.
Instance Method Summary collapse
-
#initialize(item, stream = nil) ⇒ Entry
constructor
Instantiate and normalize a new Google Reader entry.
- #mark_as_read! ⇒ Object
-
#published_at ⇒ Object
Provide the canonical publish date in
Time
format. - #share! ⇒ Object
-
#sort_by_time ⇒ Object
Provide the entry time by which the entry should be sorted amongst other entries.
-
#updated_at ⇒ Object
Provide the canonical date and time of update in
Time
format.
Constructor Details
#initialize(item, stream = nil) ⇒ Entry
Instantiate and normalize a new Google Reader entry
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/greedy/entry.rb', line 25 def initialize(item, stream = nil) @stream = stream @feed = Greedy::Feed.new(item['origin']) @author = normalize item['author'] @google_item_id = item['id'] @published = item['published'] @updated = item['updated'] set_body!(item) set_title!(item) set_href!(item) end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
3 4 5 |
# File 'lib/greedy/entry.rb', line 3 def @author end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/greedy/entry.rb', line 3 def body @body end |
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
3 4 5 |
# File 'lib/greedy/entry.rb', line 3 def categories @categories end |
#feed ⇒ Object (readonly)
Returns the value of attribute feed.
3 4 5 |
# File 'lib/greedy/entry.rb', line 3 def feed @feed end |
#google_item_id ⇒ Object (readonly)
Returns the value of attribute google_item_id.
3 4 5 |
# File 'lib/greedy/entry.rb', line 3 def google_item_id @google_item_id end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
3 4 5 |
# File 'lib/greedy/entry.rb', line 3 def href @href end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
3 4 5 |
# File 'lib/greedy/entry.rb', line 3 def stream @stream end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/greedy/entry.rb', line 3 def title @title end |
#truncated_body ⇒ Object (readonly)
Returns the value of attribute truncated_body.
3 4 5 |
# File 'lib/greedy/entry.rb', line 3 def truncated_body @truncated_body end |
Instance Method Details
#mark_as_read! ⇒ Object
54 55 56 |
# File 'lib/greedy/entry.rb', line 54 def mark_as_read! stream.change_state_for(self, States::READ) end |
#published_at ⇒ Object
Provide the canonical publish date in Time
format
45 46 47 |
# File 'lib/greedy/entry.rb', line 45 def published_at Time.at @published rescue nil end |
#share! ⇒ Object
58 59 60 |
# File 'lib/greedy/entry.rb', line 58 def share! stream.change_state_for(self, States::BROADCAST) end |
#sort_by_time ⇒ Object
Provide the entry time by which the entry should be sorted amongst other entries
40 41 42 |
# File 'lib/greedy/entry.rb', line 40 def sort_by_time (updated_at || published_at) end |
#updated_at ⇒ Object
Provide the canonical date and time of update in Time
format
50 51 52 |
# File 'lib/greedy/entry.rb', line 50 def updated_at Time.at @updated rescue nil end |