Class: Pello::Card

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pello/card.rb

Constant Summary collapse

NAME_REGEX =
/(\(([0-9.]*)\))*\s*([0-9.]*)\s*🍅*\s*(.*)/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trello_card) ⇒ Card

Returns a new instance of Card.



12
13
14
# File 'lib/pello/card.rb', line 12

def initialize(trello_card)
  @trello_card = trello_card
end

Instance Attribute Details

#trello_cardObject

Returns the value of attribute trello_card.



9
10
11
# File 'lib/pello/card.rb', line 9

def trello_card
  @trello_card
end

Instance Method Details

#extract_nameObject



22
23
24
# File 'lib/pello/card.rb', line 22

def extract_name
  name.match(NAME_REGEX)[-1]
end

#extract_pointsObject



26
27
28
29
30
# File 'lib/pello/card.rb', line 26

def extract_points
  points = name.match(NAME_REGEX)[2]
  points ||= 0
  points.to_f
end

#extract_pomodoriObject



16
17
18
19
20
# File 'lib/pello/card.rb', line 16

def extract_pomodori
  pomos = name.match(NAME_REGEX)[3]
  pomos ||= 0
  pomos.to_i
end