Class: Hypem::Blog
- Inherits:
-
Object
- Object
- Hypem::Blog
- Defined in:
- lib/hypem/blog.rb
Instance Attribute Summary collapse
-
#blog_image ⇒ Object
readonly
Returns the value of attribute blog_image.
-
#blog_image_small ⇒ Object
readonly
Returns the value of attribute blog_image_small.
-
#first_posted ⇒ Object
readonly
Returns the value of attribute first_posted.
-
#followers ⇒ Object
readonly
Returns the value of attribute followers.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_posted ⇒ Object
readonly
Returns the value of attribute last_posted.
-
#site_name ⇒ Object
readonly
Returns the value of attribute site_name.
-
#site_url ⇒ Object
readonly
Returns the value of attribute site_url.
-
#total_tracks ⇒ Object
readonly
Returns the value of attribute total_tracks.
Class Method Summary collapse
Instance Method Summary collapse
- #get_info ⇒ Object
-
#initialize(*args) ⇒ Blog
constructor
A new instance of Blog.
- #update_from_response(rsp) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Blog
Returns a new instance of Blog.
7 8 9 10 11 |
# File 'lib/hypem/blog.rb', line 7 def initialize(*args) if args.count == 1 @id = args.first.is_a?(Integer) ? args.first : args.first.to_i end end |
Instance Attribute Details
#blog_image ⇒ Object (readonly)
Returns the value of attribute blog_image.
3 4 5 |
# File 'lib/hypem/blog.rb', line 3 def blog_image @blog_image end |
#blog_image_small ⇒ Object (readonly)
Returns the value of attribute blog_image_small.
3 4 5 |
# File 'lib/hypem/blog.rb', line 3 def blog_image_small @blog_image_small end |
#first_posted ⇒ Object (readonly)
Returns the value of attribute first_posted.
3 4 5 |
# File 'lib/hypem/blog.rb', line 3 def first_posted @first_posted end |
#followers ⇒ Object (readonly)
Returns the value of attribute followers.
3 4 5 |
# File 'lib/hypem/blog.rb', line 3 def followers @followers end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/hypem/blog.rb', line 3 def id @id end |
#last_posted ⇒ Object (readonly)
Returns the value of attribute last_posted.
3 4 5 |
# File 'lib/hypem/blog.rb', line 3 def last_posted @last_posted end |
#site_name ⇒ Object (readonly)
Returns the value of attribute site_name.
3 4 5 |
# File 'lib/hypem/blog.rb', line 3 def site_name @site_name end |
#site_url ⇒ Object (readonly)
Returns the value of attribute site_url.
3 4 5 |
# File 'lib/hypem/blog.rb', line 3 def site_url @site_url end |
#total_tracks ⇒ Object (readonly)
Returns the value of attribute total_tracks.
3 4 5 |
# File 'lib/hypem/blog.rb', line 3 def total_tracks @total_tracks end |
Class Method Details
Instance Method Details
#get_info ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/hypem/blog.rb', line 13 def get_info unless @has_info response = Request.new("/api/get_site_info?siteid=#{@id}").tap(&:get).response.body update_from_response(response) @has_info = true end end |
#update_from_response(rsp) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/hypem/blog.rb', line 21 def update_from_response(rsp) @id ||= rsp[:site_id] @blog_image ||= rsp['blog_image'] @blog_image_small ||= rsp['blog_image_small'] @followers ||= rsp['followers'] @id ||= rsp['siteid'] @site_name ||= rsp['sitename'] @site_url ||= rsp['siteurl'] @total_tracks ||= rsp['total_tracks'] # only from get_info @first_posted ||= Time.at(rsp['first_posted']) unless rsp['first_posted'].nil? @last_posted ||= Time.at(rsp['last_posted']) unless rsp['last_posted'].nil? end |