Class: Rubyhexagon::Post::Score Private
- Inherits:
-
Object
- Object
- Rubyhexagon::Post::Score
- 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.
Instance Attribute Summary collapse
- #down ⇒ Object readonly private
- #total ⇒ Object readonly private
- #up ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(score) ⇒ Score
constructor
private
A new instance of Score.
- #negative? ⇒ Boolean private
- #positive? ⇒ Boolean private
- #to_i ⇒ Object private
- #zero? ⇒ Boolean private
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.
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
#down ⇒ Object (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.
29 30 31 |
# File 'lib/rubyhexagon/post/score.rb', line 29 def down @down end |
#total ⇒ Object (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.
30 31 32 |
# File 'lib/rubyhexagon/post/score.rb', line 30 def total @total end |
#up ⇒ Object (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.
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.
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.
46 47 48 |
# File 'lib/rubyhexagon/post/score.rb', line 46 def positive? @total.positive? end |
#to_i ⇒ Object
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.
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.
54 55 56 |
# File 'lib/rubyhexagon/post/score.rb', line 54 def zero? @total.zero? end |