Class: Fbtxt::Model::Penalty

Inherits:
Object
  • Object
show all
Defined in:
lib/fbtxt/document/models/penalty.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, score: nil, note: nil) ⇒ Penalty

Returns a new instance of Penalty.



14
15
16
17
18
# File 'lib/fbtxt/document/models/penalty.rb', line 14

def initialize( name:, score: nil, note: nil )
    @name    = name
    @score   = score
    @note    = note
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/fbtxt/document/models/penalty.rb', line 10

def name
  @name
end

#noteObject (readonly)

Returns the value of attribute note.



12
13
14
# File 'lib/fbtxt/document/models/penalty.rb', line 12

def note
  @note
end

#scoreObject (readonly)

Returns the value of attribute score.



11
12
13
# File 'lib/fbtxt/document/models/penalty.rb', line 11

def score
  @score
end

Instance Method Details

#as_jsonObject



25
26
27
28
29
30
31
# File 'lib/fbtxt/document/models/penalty.rb', line 25

def as_json(*)
    h = { 'name'  => name }
    h['score'] = score     if score.is_a?(Array) && !score.empty?
    h['note']  = note      if note

    h
end