Class: Twitter2Mastodon::Store
- Inherits:
-
Object
- Object
- Twitter2Mastodon::Store
- Defined in:
- lib/twitter2mastodon/store.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #add_to_store(tweet_object) ⇒ Object
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #never_been_published?(twitt) ⇒ Boolean
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
8 9 10 11 |
# File 'lib/twitter2mastodon/store.rb', line 8 def initialize @store_file = find_or_create_store @store = JSON.parse(File.read(@store_file)) end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
6 7 8 |
# File 'lib/twitter2mastodon/store.rb', line 6 def store @store end |
Instance Method Details
#add_to_store(tweet_object) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/twitter2mastodon/store.rb', line 17 def add_to_store(tweet_object) status = tweet_object id = make_hash(tweet_object) return nil unless never_been_published?(tweet_object) clean_store @store[id] = { name: status.name, message: status., uri: status.url.to_str } File.write(@store_file, @store.to_json) tweet_object end |
#never_been_published?(twitt) ⇒ Boolean
13 14 15 |
# File 'lib/twitter2mastodon/store.rb', line 13 def never_been_published?(twitt) @store.none? { |tweet| tweet[0] == make_hash(twitt) } end |