Class: Rubyhexagon::TagChange
- Inherits:
-
Object
- Object
- Rubyhexagon::TagChange
- Defined in:
- lib/rubyhexagon/tag_change.rb
Overview
This class holds post information, fetched from e621, and gives access in a more Ruby like manner.
Instance Attribute Summary collapse
-
#created_at ⇒ Time
readonly
Time of change.
-
#id ⇒ Integer
readonly
Change ID.
-
#post_id ⇒ Integer
readonly
Post ID that got updated.
-
#sources ⇒ Array<String>
readonly
New sources.
-
#tags ⇒ Array<String>
readonly
New tags.
Instance Method Summary collapse
-
#==(other) ⇒ TrueClass, FalseClass
Comparison method for tag changes.
-
#initialize(post) ⇒ Object
constructor
Initializer for TagChange.
Constructor Details
#initialize(post) ⇒ Object
Initializer for TagChange
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rubyhexagon/tag_change.rb', line 48 def initialize(post) post.each do |k, v| if k.to_s =~ /id$/ v = v.to_i unless k.to_s.match(/id$/) && v.is_a?(Integer) && v.positive? raise InvalidIDError, "ID out of range: #{v}" end end instance_variable_set("@#{k}".to_sym, v) end end |
Instance Attribute Details
#created_at ⇒ Time (readonly)
Returns time of change.
33 34 35 |
# File 'lib/rubyhexagon/tag_change.rb', line 33 def created_at @created_at end |
#id ⇒ Integer (readonly)
Returns change ID.
27 28 29 |
# File 'lib/rubyhexagon/tag_change.rb', line 27 def id @id end |
#post_id ⇒ Integer (readonly)
Returns post ID that got updated.
30 31 32 |
# File 'lib/rubyhexagon/tag_change.rb', line 30 def post_id @post_id end |
#sources ⇒ Array<String> (readonly)
Returns new sources.
39 40 41 |
# File 'lib/rubyhexagon/tag_change.rb', line 39 def sources @sources end |
#tags ⇒ Array<String> (readonly)
Returns new tags.
36 37 38 |
# File 'lib/rubyhexagon/tag_change.rb', line 36 def @tags end |
Instance Method Details
#==(other) ⇒ TrueClass, FalseClass
Comparison method for tag changes
65 66 67 |
# File 'lib/rubyhexagon/tag_change.rb', line 65 def ==(other) other.is_a?(TagChange) && @id == other.id end |