Class: Rubyhexagon::Post::Score Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyhexagon/post/score.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class for post file data. This is mostly an abstraction to have data structures in a more Ruby like nature.

Author:

  • Maxine Michalski

Since:

  • 3.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(score) ⇒ Score

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Score.

Raises:

  • (ArgumentError)

Since:

  • 3.0.0



33
34
35
36
37
38
39
40
41
# File 'lib/rubyhexagon/post/score.rb', line 33

def initialize(score)
  raise ArgumentError, 'Hash required' unless score.is_a?(Hash)
  unless score.keys.sort == %i[down total up]
    raise ArgumentError, 'Missing Hash keys.'
  end
  score.each do |k, v|
    instance_variable_set("@#{k}".to_sym, v)
  end
end

Instance Attribute Details

#downObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



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

def down
  @down
end

#totalObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



31
32
33
# File 'lib/rubyhexagon/post/score.rb', line 31

def total
  @total
end

#upObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



29
30
31
# File 'lib/rubyhexagon/post/score.rb', line 29

def up
  @up
end

Instance Method Details

#negative?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 3.0.0



51
52
53
# File 'lib/rubyhexagon/post/score.rb', line 51

def negative?
  @total.negative?
end

#positive?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 3.0.0



47
48
49
# File 'lib/rubyhexagon/post/score.rb', line 47

def positive?
  @total.positive?
end

#to_iObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



43
44
45
# File 'lib/rubyhexagon/post/score.rb', line 43

def to_i
  @total
end

#zero?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 3.0.0



55
56
57
# File 'lib/rubyhexagon/post/score.rb', line 55

def zero?
  @total.zero?
end