Class: HammerCLI::Output::Adapter::CSValues::FieldWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/hammer_cli/output/adapter/csv.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field) ⇒ FieldWrapper

Returns a new instance of FieldWrapper.



101
102
103
104
105
106
107
# File 'lib/hammer_cli/output/adapter/csv.rb', line 101

def initialize(field)
  @field = field
  @name = nil
  @prefixes = []
  @suffixes = []
  @data
end

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



95
96
97
# File 'lib/hammer_cli/output/adapter/csv.rb', line 95

def field
  @field
end

#nameObject

Returns the value of attribute name.



95
96
97
# File 'lib/hammer_cli/output/adapter/csv.rb', line 95

def name
  @name
end

Class Method Details

.wrap(fields) ⇒ Object



97
98
99
# File 'lib/hammer_cli/output/adapter/csv.rb', line 97

def self.wrap(fields)
  fields.map{ |f| FieldWrapper.new(f) }
end

Instance Method Details

#append_prefix(prefix) ⇒ Object



113
114
115
# File 'lib/hammer_cli/output/adapter/csv.rb', line 113

def append_prefix(prefix)
  @prefixes << prefix
end

#append_suffix(suffix) ⇒ Object



109
110
111
# File 'lib/hammer_cli/output/adapter/csv.rb', line 109

def append_suffix(suffix)
  @suffixes << suffix
end

#display_nameObject



125
126
127
128
129
130
131
# File 'lib/hammer_cli/output/adapter/csv.rb', line 125

def display_name
  names = []
  names << prefix unless prefix.empty?
  names << @field.label if @field.label
  names << suffix unless suffix.empty?
  names.join("::")
end

#is_id?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/hammer_cli/output/adapter/csv.rb', line 133

def is_id?
  self.field.class <= Fields::Id
end

#prefixObject



117
118
119
# File 'lib/hammer_cli/output/adapter/csv.rb', line 117

def prefix
  @prefixes.join("::")
end

#suffixObject



121
122
123
# File 'lib/hammer_cli/output/adapter/csv.rb', line 121

def suffix
  @suffixes.join("::")
end