Class: BinData::SanitizedFields

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

Overview


Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hints) ⇒ SanitizedFields

Returns a new instance of SanitizedFields.



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

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

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



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

def fields
  @fields
end

Instance Method Details

#[](idx) ⇒ Object



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

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

#add_field(type, name, params) ⇒ Object



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

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

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

#all_field_names_blank?Boolean

Returns:

  • (Boolean)


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

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

#any_field_has_parameter?(parameter) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#copy_fields(other) ⇒ Object



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

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

#each(&block) ⇒ Object



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

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  @fields.empty?
end

#field_namesObject



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

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

#has_field_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#lengthObject



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

def length
  @fields.length
end

#no_field_names_blank?Boolean

Returns:

  • (Boolean)


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

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