Class: SilverMother::Feed

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/silver_mother/feed.rb

Constant Summary collapse

FEEDS_PATH =
'feeds/'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#feed_cacheObject (readonly)

Returns the value of attribute feed_cache.



9
10
11
# File 'lib/silver_mother/feed.rb', line 9

def feed_cache
  @feed_cache
end

#feedsObject (readonly)

Returns the value of attribute feeds.



9
10
11
# File 'lib/silver_mother/feed.rb', line 9

def feeds
  @feeds
end

#feeds_rawObject (readonly)

Returns the value of attribute feeds_raw.



9
10
11
# File 'lib/silver_mother/feed.rb', line 9

def feeds_raw
  @feeds_raw
end

#uidsObject (readonly)

Returns the value of attribute uids.



9
10
11
# File 'lib/silver_mother/feed.rb', line 9

def uids
  @uids
end

Instance Method Details

#call(token) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/silver_mother/feed.rb', line 11

def call(token)
  @token = token
  @feeds_raw = []
  @response = Api.instance.get(FEEDS_PATH, @token)
  @feeds_raw << @response
  while next_page
    new_path = FEEDS_PATH + next_page_number
    @response = Api.instance.get(new_path, @token)
    @feeds_raw << @response
  end
end

#clear_cache!Object



43
44
45
46
47
48
# File 'lib/silver_mother/feed.rb', line 43

def clear_cache!
  @feeds_raw  = []
  @feeds      = []
  @uids       = []
  @feed_cache = {}
end

#feed(uid) ⇒ Object



37
38
39
40
41
# File 'lib/silver_mother/feed.rb', line 37

def feed(uid)
  feed_path = FEEDS_PATH + uid + '/'
  @feed_cache ||= {}
  @feed_cache[uid] ||= Api.instance.get(feed_path, @token).to_ostruct
end