Class: Pomodoro::Commands::Active::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/pomodoro/commands/active.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, pattern, &block) ⇒ Formatter

Returns a new instance of Formatter.


7
8
9
# File 'lib/pomodoro/commands/active.rb', line 7

def initialize(name, pattern, &block)
  @name, @pattern, @block = name, pattern, block
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


6
7
8
# File 'lib/pomodoro/commands/active.rb', line 6

def name
  @name
end

#patternObject (readonly)

Returns the value of attribute pattern


6
7
8
# File 'lib/pomodoro/commands/active.rb', line 6

def pattern
  @pattern
end

Instance Method Details

#call(time_frame, active_task) ⇒ Object


15
16
17
18
# File 'lib/pomodoro/commands/active.rb', line 15

def call(time_frame, active_task)
  block = @block || Proc.new { |_, t| t.send(@name) }
  block.call(time_frame, active_task)
end

#exampleObject


11
12
13
# File 'lib/pomodoro/commands/active.rb', line 11

def example
  Pomodoro::Commands::Active.t("examples.#{@name}")
end