Class: Fbtxt::Model::EventCard

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

Overview

e.g. 'Y', Player, 44 'YR', Player, 45+2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, name:, minute: nil) ⇒ EventCard

Returns a new instance of EventCard.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fbtxt/document/models/event.rb', line 16

def initialize( type:, name:, minute: nil )
    @type   = type
    @name   = name

    ## note - auto-convert to our own Minute format
    @minute =  if minute.is_a?( RaccMatchParser::Minute )
                    Minute.new( m:      minute.m,
                                offset: minute.offset,
                                secs:   minute.secs )
               else
                minute
               end
end

Instance Attribute Details

#minuteObject (readonly)

Returns the value of attribute minute.



14
15
16
# File 'lib/fbtxt/document/models/event.rb', line 14

def minute
  @minute
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/fbtxt/document/models/event.rb', line 13

def name
  @name
end

#typeObject (readonly)

use EventBooking - why? why not?



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

def type
  @type
end

Instance Method Details

#as_jsonObject



31
32
33
34
35
36
37
# File 'lib/fbtxt/document/models/event.rb', line 31

def as_json(*)
    h = { 'type' => type,
          'name' => name }
    h['minute'] = minute.to_s    if minute

    h
end