Class: Flycal::Pipeline::Params

Inherits:
Object
  • Object
show all
Defined in:
lib/flycal/pipeline/params.rb

Overview

Mutable bag of CLI + derived parameters passed through the pipeline.

Instance Method Summary collapse

Constructor Details

#initialize(initial = {}) ⇒ Params

Returns a new instance of Params.



7
8
9
10
# File 'lib/flycal/pipeline/params.rb', line 7

def initialize(initial = {})
  @data = {}
  initial.each { |k, v| self[k] = v }
end

Instance Method Details

#[](key) ⇒ Object



12
13
14
# File 'lib/flycal/pipeline/params.rb', line 12

def [](key)
  @data[key.to_sym]
end

#[]=(key, value) ⇒ Object



16
17
18
# File 'lib/flycal/pipeline/params.rb', line 16

def []=(key, value)
  @data[key.to_sym] = value
end

#each(&block) ⇒ Object



41
42
43
# File 'lib/flycal/pipeline/params.rb', line 41

def each(&block)
  @data.each(&block)
end

#fetch(key, default = nil, &block) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/flycal/pipeline/params.rb', line 20

def fetch(key, default = nil, &block)
  if block
    @data.fetch(key.to_sym, &block)
  else
    @data.fetch(key.to_sym, default)
  end
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/flycal/pipeline/params.rb', line 28

def key?(key)
  @data.key?(key.to_sym)
end

#merge!(other) ⇒ Object



32
33
34
35
# File 'lib/flycal/pipeline/params.rb', line 32

def merge!(other)
  other.each { |k, v| self[k] = v }
  self
end

#to_hObject



37
38
39
# File 'lib/flycal/pipeline/params.rb', line 37

def to_h
  @data.dup
end