Class: Sports::League

Inherits:
Object
  • Object
show all
Defined in:
lib/sportdb/structs/league.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, name:, alt_names: [], country: nil, intl: false, clubs: true) ⇒ League

Returns a new instance of League.



10
11
12
13
14
15
16
17
18
19
# File 'lib/sportdb/structs/league.rb', line 10

def initialize( key:, name:, alt_names: [],
                country: nil, intl: false, clubs: true )
  @key            = key
  @name           = name
  @alt_names      = alt_names
 
  @country        = country
  @intl           = intl
  @clubs          = clubs
end

Instance Attribute Details

#alt_namesObject

Returns the value of attribute alt_names.



7
8
9
# File 'lib/sportdb/structs/league.rb', line 7

def alt_names
  @alt_names
end

#countryObject (readonly)

Returns the value of attribute country.



6
7
8
# File 'lib/sportdb/structs/league.rb', line 6

def country
  @country
end

#intlObject (readonly)

Returns the value of attribute intl.



6
7
8
# File 'lib/sportdb/structs/league.rb', line 6

def intl
  @intl
end

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/sportdb/structs/league.rb', line 6

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/sportdb/structs/league.rb', line 6

def name
  @name
end

Instance Method Details

#clubs?Boolean Also known as: club?

Returns:

  • (Boolean)


25
# File 'lib/sportdb/structs/league.rb', line 25

def clubs?()            @clubs == true; end

#intl?Boolean

Returns:

  • (Boolean)


21
# File 'lib/sportdb/structs/league.rb', line 21

def intl?()      @intl == true; end

#national?Boolean Also known as: domestic?

Returns:

  • (Boolean)


22
# File 'lib/sportdb/structs/league.rb', line 22

def national?()  @intl == false; end

#national_teams?Boolean Also known as: national_team?

Returns:

  • (Boolean)


26
# File 'lib/sportdb/structs/league.rb', line 26

def national_teams?()   @clubs == false; end

#pretty_print(printer) ⇒ Object

@alt_names=[],

@clubs=true,
@country=<Country: at - Austria (AUT)|Österreich [de], fifa|uefa)>,
@intl=false,
@key="at.1",
@name="Bundesliga">,


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sportdb/structs/league.rb', line 39

def pretty_print( printer ) 
  buf = String.new
  buf << "<League"
  buf << " INTL"   if @intl
  buf <<   if @clubs 
               " CLUBS" 
           else 
               " NATIONAL TEAMS"
           end  
  buf << ": #{@key} - #{@name}"
  buf << "|#{@alt_names.join('|')}"  if @alt_names && !@alt_names.empty?
  buf << ", #{@country.name} (#{@country.code})"     if @country
  buf << ">"

  printer.text( buf ) 
end