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.



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

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

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



86
87
88
# File 'lib/hammer_cli/output/adapter/csv.rb', line 86

def field
  @field
end

#nameObject

Returns the value of attribute name.



86
87
88
# File 'lib/hammer_cli/output/adapter/csv.rb', line 86

def name
  @name
end

Class Method Details

.wrap(fields) ⇒ Object



88
89
90
# File 'lib/hammer_cli/output/adapter/csv.rb', line 88

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

Instance Method Details

#append_prefix(prefix) ⇒ Object



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

def append_prefix(prefix)
  @prefixes << prefix
end

#append_suffix(suffix) ⇒ Object



99
100
101
# File 'lib/hammer_cli/output/adapter/csv.rb', line 99

def append_suffix(suffix)
  @suffixes << suffix
end

#display_nameObject



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

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)


123
124
125
# File 'lib/hammer_cli/output/adapter/csv.rb', line 123

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

#prefixObject



107
108
109
# File 'lib/hammer_cli/output/adapter/csv.rb', line 107

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

#suffixObject



111
112
113
# File 'lib/hammer_cli/output/adapter/csv.rb', line 111

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