Class: MapSource::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/mapsource/defs.rb

Overview

Public: A Color attributed to a Track, Route or Waypoint.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, r = -1,, g = -1,, b = -1)) ⇒ Color

Returns a new instance of Color.



6
7
8
9
10
11
# File 'lib/mapsource/defs.rb', line 6

def initialize(name, r=-1, g=-1, b=-1)
  @name = name
  @r = @r
  @g = @g
  @b = @b
end

Instance Attribute Details

#bObject (readonly)

Returns the value of attribute b.



4
5
6
# File 'lib/mapsource/defs.rb', line 4

def b
  @b
end

#gObject (readonly)

Returns the value of attribute g.



4
5
6
# File 'lib/mapsource/defs.rb', line 4

def g
  @g
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/mapsource/defs.rb', line 4

def name
  @name
end

#rObject (readonly)

Returns the value of attribute r.



4
5
6
# File 'lib/mapsource/defs.rb', line 4

def r
  @r
end

Class Method Details

.from_index(idx) ⇒ Object

Public: Converts GDB color index to color object.

idx - GDB index

Returns Color corresponding to index.



18
19
20
# File 'lib/mapsource/defs.rb', line 18

def self.from_index(idx)
  COLORS[idx] || COLORS.first
end