Class: Stackup::RakeTasks::DataOption

Inherits:
Object
  • Object
show all
Defined in:
lib/stackup/rake_tasks.rb

Overview

A flag with optional argument that will be passed to stackup

Direct Known Subclasses

DataOptionArray, DataOptionFile, DataOptionHash

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flag, argument) ⇒ DataOption

Returns a new instance of DataOption.



84
85
86
87
# File 'lib/stackup/rake_tasks.rb', line 84

def initialize(flag, argument)
  @flag = flag
  @argument = argument
end

Instance Attribute Details

#argumentObject (readonly)

Returns the value of attribute argument.



107
108
109
# File 'lib/stackup/rake_tasks.rb', line 107

def argument
  @argument
end

#flagObject (readonly)

Returns the value of attribute flag.



106
107
108
# File 'lib/stackup/rake_tasks.rb', line 106

def flag
  @flag
end

Class Method Details

.for(flag, argument) ⇒ Object

Factory method for initialising DataOptions based on class



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/stackup/rake_tasks.rb', line 94

def self.for(flag, argument)
  if argument.is_a?(Hash)
    DataOptionHash.new(flag, argument)
  elsif argument.is_a?(Array)
    DataOptionArray.new(flag, argument)
  elsif argument.is_a?(String) && File.exist?(argument)
    DataOptionFile.new(flag, argument)
  else
    DataOption.new(flag, argument)
  end
end

Instance Method Details

#to_aObject



89
90
91
# File 'lib/stackup/rake_tasks.rb', line 89

def to_a
  [@flag, @argument]
end