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.

Since:

  • 3.0.0

API:

  • private

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:

Since:

  • 3.0.0

API:

  • private



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

API:

  • private



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

API:

  • private



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

API:

  • private



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:

Since:

  • 3.0.0

API:

  • private



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:

Since:

  • 3.0.0

API:

  • private



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

API:

  • private



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:

Since:

  • 3.0.0

API:

  • private



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

def zero?
  @total.zero?
end