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.



48
49
50
51
# File 'lib/bindata/sanitize.rb', line 48

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

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



52
53
54
# File 'lib/bindata/sanitize.rb', line 52

def fields
  @fields
end

Instance Method Details

#[](idx) ⇒ Object



60
61
62
# File 'lib/bindata/sanitize.rb', line 60

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

#add_field(type, name, params) ⇒ Object



54
55
56
57
58
# File 'lib/bindata/sanitize.rb', line 54

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)


88
89
90
# File 'lib/bindata/sanitize.rb', line 88

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

#collect(&block) ⇒ Object



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

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

#copy_fields(other) ⇒ Object



96
97
98
# File 'lib/bindata/sanitize.rb', line 96

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

#each(&block) ⇒ Object



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

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

#empty?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/bindata/sanitize.rb', line 64

def empty?
  @fields.empty?
end

#field_namesObject



80
81
82
# File 'lib/bindata/sanitize.rb', line 80

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

#has_field_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/bindata/sanitize.rb', line 84

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

#lengthObject



68
69
70
# File 'lib/bindata/sanitize.rb', line 68

def length
  @fields.length
end

#no_field_names_blank?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/bindata/sanitize.rb', line 92

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