Class: TrackingFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/trello_effort_tracker/tracking_factory.rb

Constant Summary collapse

DURATION_REGEXP =
'(\d+\.?\d*[phdg])'

Class Method Summary collapse

Class Method Details

.build_from(tracking_notification) ⇒ Object



11
12
13
14
15
16
# File 'lib/trello_effort_tracker/tracking_factory.rb', line 11

def self.build_from(tracking_notification)
  matching_pair = @match_pairs.find { |regexp, tracking_class| tracking_notification.data['text'] =~ regexp }

  tracking_class = matching_pair ? matching_pair.last : Tracking::InvalidTracking
  tracking_class.new(tracking_notification)
end

.match(match_pair) ⇒ Object



7
8
9
# File 'lib/trello_effort_tracker/tracking_factory.rb', line 7

def self.match(match_pair)
  @match_pairs.merge!(match_pair)
end