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.



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

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

Instance Attribute Details

#argumentObject (readonly)

Returns the value of attribute argument.



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

def argument
  @argument
end

#flagObject (readonly)

Returns the value of attribute flag.



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

def flag
  @flag
end

Class Method Details

.for(flag, argument) ⇒ Object

Factory method for initialising DataOptions based on class



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

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



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

def to_a
  [@flag, @argument]
end