Class: Kisaweb::ListItem

Inherits:
Object show all
Defined in:
lib/kisaweb/list_item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#pointsObject

Returns the value of attribute points.



3
4
5
# File 'lib/kisaweb/list_item.rb', line 3

def points
  @points
end

#positionObject

Returns the value of attribute position.



3
4
5
# File 'lib/kisaweb/list_item.rb', line 3

def position
  @position
end

#runnerObject

Returns the value of attribute runner.



3
4
5
# File 'lib/kisaweb/list_item.rb', line 3

def runner
  @runner
end

#runsObject

Returns the value of attribute runs.



3
4
5
# File 'lib/kisaweb/list_item.rb', line 3

def runs
  @runs
end

Class Method Details

.from_array(arr) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kisaweb/list_item.rb', line 5

def self.from_array(arr)
  item = new
  item.position = arr.first.to_i
  item.points = BigDecimal.new(arr.last)
  item.runner = Runner.new(*arr[1, 4])
  item.runs = []

  5.step(13, 2) do |i|
    next unless arr[i]

    item.runs << Run.new(arr[i], arr[i + 1])
  end

  item
end