Class: BinData::SanitizedFields
- Inherits:
-
SanitizedParameter
- Object
- SanitizedParameter
- BinData::SanitizedFields
- Defined in:
- lib/bindata/sanitize.rb
Overview
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #[](idx) ⇒ Object
- #add_field(type, name, params) ⇒ Object
- #all_field_names_blank? ⇒ Boolean
- #collect(&block) ⇒ Object
- #copy_fields(other) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #field_names ⇒ Object
- #has_field_name?(name) ⇒ Boolean
-
#initialize(endian) ⇒ SanitizedFields
constructor
A new instance of SanitizedFields.
- #length ⇒ Object
- #no_field_names_blank? ⇒ Boolean
Constructor Details
#initialize(endian) ⇒ SanitizedFields
Returns a new instance of SanitizedFields.
57 58 59 60 |
# File 'lib/bindata/sanitize.rb', line 57 def initialize(endian) @fields = [] @endian = endian end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
61 62 63 |
# File 'lib/bindata/sanitize.rb', line 61 def fields @fields end |
Instance Method Details
#[](idx) ⇒ Object
69 70 71 |
# File 'lib/bindata/sanitize.rb', line 69 def [](idx) @fields[idx] end |
#add_field(type, name, params) ⇒ Object
63 64 65 66 67 |
# File 'lib/bindata/sanitize.rb', line 63 def add_field(type, name, params) name = nil if name == "" @fields << SanitizedField.new(name, type, params, @endian) end |
#all_field_names_blank? ⇒ Boolean
97 98 99 |
# File 'lib/bindata/sanitize.rb', line 97 def all_field_names_blank? @fields.all? { |f| f.name == nil } end |
#collect(&block) ⇒ Object
85 86 87 |
# File 'lib/bindata/sanitize.rb', line 85 def collect(&block) @fields.collect(&block) end |
#copy_fields(other) ⇒ Object
105 106 107 |
# File 'lib/bindata/sanitize.rb', line 105 def copy_fields(other) @fields.concat(other.fields) end |
#each(&block) ⇒ Object
81 82 83 |
# File 'lib/bindata/sanitize.rb', line 81 def each(&block) @fields.each(&block) end |
#empty? ⇒ Boolean
73 74 75 |
# File 'lib/bindata/sanitize.rb', line 73 def empty? @fields.empty? end |
#field_names ⇒ Object
89 90 91 |
# File 'lib/bindata/sanitize.rb', line 89 def field_names @fields.collect { |field| field.name_as_sym } end |
#has_field_name?(name) ⇒ Boolean
93 94 95 |
# File 'lib/bindata/sanitize.rb', line 93 def has_field_name?(name) @fields.detect { |f| f.name_as_sym == name.to_sym } end |
#length ⇒ Object
77 78 79 |
# File 'lib/bindata/sanitize.rb', line 77 def length @fields.length end |
#no_field_names_blank? ⇒ Boolean
101 102 103 |
# File 'lib/bindata/sanitize.rb', line 101 def no_field_names_blank? @fields.all? { |f| f.name != nil } end |