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.
58 59 60 61 |
# File 'lib/bindata/sanitize.rb', line 58 def initialize(endian) @fields = [] @endian = endian end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
62 63 64 |
# File 'lib/bindata/sanitize.rb', line 62 def fields @fields end |
Instance Method Details
#[](idx) ⇒ Object
70 71 72 |
# File 'lib/bindata/sanitize.rb', line 70 def [](idx) @fields[idx] end |
#add_field(type, name, params) ⇒ Object
64 65 66 67 68 |
# File 'lib/bindata/sanitize.rb', line 64 def add_field(type, name, params) name = nil if name == "" @fields << SanitizedField.new(name, type, params, @endian) end |
#all_field_names_blank? ⇒ Boolean
98 99 100 |
# File 'lib/bindata/sanitize.rb', line 98 def all_field_names_blank? @fields.all? { |f| f.name == nil } end |
#collect(&block) ⇒ Object
86 87 88 |
# File 'lib/bindata/sanitize.rb', line 86 def collect(&block) @fields.collect(&block) end |
#copy_fields(other) ⇒ Object
106 107 108 |
# File 'lib/bindata/sanitize.rb', line 106 def copy_fields(other) @fields.concat(other.fields) end |
#each(&block) ⇒ Object
82 83 84 |
# File 'lib/bindata/sanitize.rb', line 82 def each(&block) @fields.each(&block) end |
#empty? ⇒ Boolean
74 75 76 |
# File 'lib/bindata/sanitize.rb', line 74 def empty? @fields.empty? end |
#field_names ⇒ Object
90 91 92 |
# File 'lib/bindata/sanitize.rb', line 90 def field_names @fields.collect { |field| field.name_as_sym } end |
#has_field_name?(name) ⇒ Boolean
94 95 96 |
# File 'lib/bindata/sanitize.rb', line 94 def has_field_name?(name) @fields.detect { |f| f.name_as_sym == name.to_sym } end |
#length ⇒ Object
78 79 80 |
# File 'lib/bindata/sanitize.rb', line 78 def length @fields.length end |
#no_field_names_blank? ⇒ Boolean
102 103 104 |
# File 'lib/bindata/sanitize.rb', line 102 def no_field_names_blank? @fields.all? { |f| f.name != nil } end |