Class: Firuta::Commands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/firuta/commands/base.rb

Direct Known Subclasses

Filter, Find, Paginate, Reduce, Sort, Uniq

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(function, params = nil) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/firuta/commands/base.rb', line 6

def initialize(function, params = nil)
  @proc = function
  @params = [params].flatten.compact
end

Class Method Details

.terminal?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/firuta/commands/base.rb', line 20

def self.terminal?
  false
end

Instance Method Details

#apply_to(*_params) ⇒ Object



16
17
18
# File 'lib/firuta/commands/base.rb', line 16

def apply_to(*_params)
  raise Errors::SubclassMustImplement
end

#call(element) ⇒ Object



11
12
13
14
# File 'lib/firuta/commands/base.rb', line 11

def call(element)
  return @proc.call(element) if @params.empty?
  @proc.call(element, *@params)
end