Class: HammerCLI::Output::Adapter::CSValues::FieldWrapper
- Inherits:
-
Object
- Object
- HammerCLI::Output::Adapter::CSValues::FieldWrapper
- Defined in:
- lib/hammer_cli/output/adapter/csv.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #append_prefix(prefix) ⇒ Object
- #append_suffix(suffix) ⇒ Object
- #display_name ⇒ Object
-
#initialize(field) ⇒ FieldWrapper
constructor
A new instance of FieldWrapper.
- #is_id? ⇒ Boolean
- #prefix ⇒ Object
- #suffix ⇒ Object
Constructor Details
#initialize(field) ⇒ FieldWrapper
Returns a new instance of FieldWrapper.
92 93 94 95 96 97 98 |
# File 'lib/hammer_cli/output/adapter/csv.rb', line 92 def initialize(field) @field = field @name = nil @prefixes = [] @suffixes = [] @data end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
86 87 88 |
# File 'lib/hammer_cli/output/adapter/csv.rb', line 86 def field @field end |
#name ⇒ Object
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
104 105 106 |
# File 'lib/hammer_cli/output/adapter/csv.rb', line 104 def append_prefix(prefix) @prefixes << prefix end |
#append_suffix(suffix) ⇒ Object
100 101 102 |
# File 'lib/hammer_cli/output/adapter/csv.rb', line 100 def append_suffix(suffix) @suffixes << suffix end |
#display_name ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/hammer_cli/output/adapter/csv.rb', line 116 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
124 125 126 |
# File 'lib/hammer_cli/output/adapter/csv.rb', line 124 def is_id? self.field.class <= Fields::Id end |
#prefix ⇒ Object
108 109 110 |
# File 'lib/hammer_cli/output/adapter/csv.rb', line 108 def prefix @prefixes.join("::") end |
#suffix ⇒ Object
112 113 114 |
# File 'lib/hammer_cli/output/adapter/csv.rb', line 112 def suffix @suffixes.join("::") end |