Module: Titi::Fetcher::Json::ClassMethods
- Defined in:
- lib/titi/fetcher/json.rb
Instance Method Summary collapse
- #from_file(filename) ⇒ Object
-
#get(url) ⇒ Object
Call the twitter API and fetch tweet with given ID.
- #parse(raw_json_str) ⇒ Object
Instance Method Details
#from_file(filename) ⇒ Object
25 26 27 |
# File 'lib/titi/fetcher/json.rb', line 25 def from_file filename parse File.open(filename) end |
#get(url) ⇒ Object
Call the twitter API and fetch tweet with given ID
21 22 23 |
# File 'lib/titi/fetcher/json.rb', line 21 def get url parse RestClient.get(url).to_s end |
#parse(raw_json_str) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/titi/fetcher/json.rb', line 5 def parse raw_json_str begin return JSON.load(raw_json_str) rescue StandardError => e warn e return { } end end |