Class: Score
- Inherits:
-
Object
- Object
- Score
- Defined in:
- lib/fbtxt-pp/models/score.rb
Instance Attribute Summary collapse
-
#agg ⇒ Object
readonly
Returns the value of attribute agg.
-
#et ⇒ Object
readonly
Returns the value of attribute et.
-
#ft ⇒ Object
readonly
Returns the value of attribute ft.
-
#ht ⇒ Object
readonly
Returns the value of attribute ht.
-
#p ⇒ Object
readonly
Returns the value of attribute p.
-
#reported ⇒ Object
readonly
Returns the value of attribute reported.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ht: nil, ft: nil, et: nil, p: nil, agg: nil, reported: nil, score: nil) ⇒ Score
constructor
A new instance of Score.
- #to_s ⇒ Object
Constructor Details
#initialize(ht: nil, ft: nil, et: nil, p: nil, agg: nil, reported: nil, score: nil) ⇒ Score
Returns a new instance of Score.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fbtxt-pp/models/score.rb', line 23 def initialize( ht: nil, ft: nil, et: nil, p: nil, agg: nil, reported: nil, score: nil ) @ht, @ft, @et, @p, @agg = ht, ft, et, p, agg ## ## note: use reported for "generic" score where ## period is not known (might be full-time or aet) ## or undefined e.g. for abandoned or awarded (administered) score @reported = reported if score puts " DEPRECATED - score got score keyword (use reported):" pp [ ht, ft, et, p, agg, reported, score] @reported = score end end |
Instance Attribute Details
#agg ⇒ Object (readonly)
Returns the value of attribute agg.
19 20 21 |
# File 'lib/fbtxt-pp/models/score.rb', line 19 def agg @agg end |
#et ⇒ Object (readonly)
Returns the value of attribute et.
19 20 21 |
# File 'lib/fbtxt-pp/models/score.rb', line 19 def et @et end |
#ft ⇒ Object (readonly)
Returns the value of attribute ft.
19 20 21 |
# File 'lib/fbtxt-pp/models/score.rb', line 19 def ft @ft end |
#ht ⇒ Object (readonly)
Returns the value of attribute ht.
19 20 21 |
# File 'lib/fbtxt-pp/models/score.rb', line 19 def ht @ht end |
#p ⇒ Object (readonly)
Returns the value of attribute p.
19 20 21 |
# File 'lib/fbtxt-pp/models/score.rb', line 19 def p @p end |
#reported ⇒ Object (readonly)
Returns the value of attribute reported.
19 20 21 |
# File 'lib/fbtxt-pp/models/score.rb', line 19 def reported @reported end |
Class Method Details
.build(score) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fbtxt-pp/models/score.rb', line 5 def self.build( score ) if score.nil? raise ArgumentError, "Score.build - expected Hash or Array; got nil" elsif score.is_a?(Hash) new( **score.transform_keys(&:to_sym) ) elsif score.is_a?(Array) new( reported: score ) else raise ArgumentError, "Score.build - expected Hash or Array; got type #{score} #{score.class.name}" end end |
Instance Method Details
#to_s ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fbtxt-pp/models/score.rb', line 43 def to_s if @reported ## check for ary empty - why? why not? "#{@reported[0]}-#{@reported[1]}" else if @et && @p if @ft && @ht "#{@et[0]}-#{@et[1]} a.e.t." + " (#{@ft[0]}-#{@ft[1]}, #{@ht[0]}-#{@ht[1]}), " + "#{@p[0]}-#{@p[1]} pen." elsif @ft "#{@et[0]}-#{@et[1]} a.e.t." + " (#{@ft[0]}-#{@ft[1]}), " + "#{@p[0]}-#{@p[1]} pen." else "#{@et[0]}-#{@et[1]} a.e.t., " + "#{@p[0]}-#{@p[1]} pen." end elsif @et && @p.nil? if @ft && @ht "#{@et[0]}-#{@et[1]} a.e.t."+ " (#{@ft[0]}-#{@ft[1]}, #{@ht[0]}-#{@ht[1]})" elsif @ft "#{@et[0]}-#{@et[1]} a.e.t."+ " (#{@ft[0]}-#{@ft[1]})" else "#{@et[0]}-#{@et[1]} a.e.t." end elsif @ft && @et.nil? && @p.nil? if @ht "#{@ft[0]}-#{@ft[1]} (#{@ht[0]}-#{@ht[1]})" else "#{@ft[0]}-#{@ft[1]}" end else ## raise error/warn - about unknown (or empty) score type - why? why not? '' end end end |