Class: RedBlocks::Expression
- Inherits:
-
Object
- Object
- RedBlocks::Expression
- Defined in:
- lib/red_blocks/expression.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#label ⇒ Object
Returns the value of attribute label.
-
#score ⇒ Object
Returns the value of attribute score.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(key, score: nil, weight: 1, label: nil) ⇒ Expression
constructor
A new instance of Expression.
- #to_s ⇒ Object
Constructor Details
#initialize(key, score: nil, weight: 1, label: nil) ⇒ Expression
Returns a new instance of Expression.
5 6 7 8 9 10 |
# File 'lib/red_blocks/expression.rb', line 5 def initialize(key, score: nil, weight: 1, label: nil) @score = score @weight = weight @key = key @label = label end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
3 4 5 |
# File 'lib/red_blocks/expression.rb', line 3 def key @key end |
#label ⇒ Object
Returns the value of attribute label.
3 4 5 |
# File 'lib/red_blocks/expression.rb', line 3 def label @label end |
#score ⇒ Object
Returns the value of attribute score.
3 4 5 |
# File 'lib/red_blocks/expression.rb', line 3 def score @score end |
#weight ⇒ Object
Returns the value of attribute weight.
3 4 5 |
# File 'lib/red_blocks/expression.rb', line 3 def weight @weight end |
Instance Method Details
#to_s ⇒ Object
16 17 18 19 |
# File 'lib/red_blocks/expression.rb', line 16 def to_s socre_str = score ? '%0.4f' % (score * weight) : '?' "#{socre_str}[#{label}]" end |