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.



57
58
59
60
# File 'lib/bindata/sanitize.rb', line 57

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

Instance Attribute Details

#fieldsObject (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

Returns:

  • (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

Returns:

  • (Boolean)


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

def empty?
  @fields.empty?
end

#field_namesObject



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

Returns:

  • (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

#lengthObject



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

def length
  @fields.length
end

#no_field_names_blank?Boolean

Returns:

  • (Boolean)


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

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