Class: Rubyhexagon::TagChange

Inherits:
Object
  • Object
show all
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.

Author:

  • Maxine Michalski

Since:

  • 1.4.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(post) ⇒ Object

Initializer for TagChange

Parameters:

  • post (Hash)

Author:

  • Maxine Michalski

Since:

  • 1.4.0



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_atTime (readonly)

Returns time of change.

Returns:

  • (Time)

    time of change

Since:

  • 1.4.0



33
34
35
# File 'lib/rubyhexagon/tag_change.rb', line 33

def created_at
  @created_at
end

#idInteger (readonly)

Returns change ID.

Returns:

  • (Integer)

    change ID

Since:

  • 1.4.0



27
28
29
# File 'lib/rubyhexagon/tag_change.rb', line 27

def id
  @id
end

#post_idInteger (readonly)

Returns post ID that got updated.

Returns:

  • (Integer)

    post ID that got updated

Since:

  • 1.4.0



30
31
32
# File 'lib/rubyhexagon/tag_change.rb', line 30

def post_id
  @post_id
end

#sourcesArray<String> (readonly)

Returns new sources.

Returns:

  • (Array<String>)

    new sources

Since:

  • 1.4.0



39
40
41
# File 'lib/rubyhexagon/tag_change.rb', line 39

def sources
  @sources
end

#tagsArray<String> (readonly)

Returns new tags.

Returns:

  • (Array<String>)

    new tags

Since:

  • 1.4.0



36
37
38
# File 'lib/rubyhexagon/tag_change.rb', line 36

def tags
  @tags
end

Instance Method Details

#==(other) ⇒ TrueClass, FalseClass

Comparison method for tag changes

Returns:

  • (TrueClass, FalseClass)

Author:

  • Maxine Michalski

Since:

  • 1.4.0



65
66
67
# File 'lib/rubyhexagon/tag_change.rb', line 65

def ==(other)
  other.is_a?(TagChange) && @id == other.id
end