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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

def zero?
  @total.zero?
end