Class: BinData::SanitizedFields

Inherits:
SanitizedParameter show all
Defined in:
lib/bindata/sanitize.rb

Overview


Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endian) ⇒ SanitizedFields

Returns a new instance of SanitizedFields.



70
71
72
73
# File 'lib/bindata/sanitize.rb', line 70

def initialize(endian)
  @fields = []
  @endian = endian
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



74
75
76
# File 'lib/bindata/sanitize.rb', line 74

def fields
  @fields
end

Instance Method Details

#[](idx) ⇒ Object



82
83
84
# File 'lib/bindata/sanitize.rb', line 82

def [](idx)
  @fields[idx]
end

#add_field(type, name, params) ⇒ Object



76
77
78
79
80
# File 'lib/bindata/sanitize.rb', line 76

def add_field(type, name, params)
  name = nil if name == ""

  @fields << SanitizedField.new(name, type, params, @endian)
end

#all_field_names_blank?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/bindata/sanitize.rb', line 114

def all_field_names_blank?
  @fields.all? { |f| f.name == nil }
end

#any_field_has_parameter?(parameter) ⇒ Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/bindata/sanitize.rb', line 122

def any_field_has_parameter?(parameter)
  @fields.any? { |f| f.has_parameter?(parameter) }
end

#collect(&block) ⇒ Object



102
103
104
# File 'lib/bindata/sanitize.rb', line 102

def collect(&block)
  @fields.collect(&block)
end

#copy_fields(other) ⇒ Object



126
127
128
# File 'lib/bindata/sanitize.rb', line 126

def copy_fields(other)
  @fields.concat(other.fields)
end

#each(&block) ⇒ Object



94
95
96
# File 'lib/bindata/sanitize.rb', line 94

def each(&block)
  @fields.each(&block)
end

#each_with_index(&block) ⇒ Object



98
99
100
# File 'lib/bindata/sanitize.rb', line 98

def each_with_index(&block)
  @fields.each_with_index(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/bindata/sanitize.rb', line 86

def empty?
  @fields.empty?
end

#field_namesObject



106
107
108
# File 'lib/bindata/sanitize.rb', line 106

def field_names
  @fields.collect { |field| field.name_as_sym }
end

#has_field_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/bindata/sanitize.rb', line 110

def has_field_name?(name)
  @fields.detect { |f| f.name_as_sym == name.to_sym }
end

#lengthObject



90
91
92
# File 'lib/bindata/sanitize.rb', line 90

def length
  @fields.length
end

#no_field_names_blank?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/bindata/sanitize.rb', line 118

def no_field_names_blank?
  @fields.all? { |f| f.name != nil }
end