Class: BootstrapFormBuilder::StringList
- Inherits:
-
Array
- Object
- Array
- BootstrapFormBuilder::StringList
- Defined in:
- lib/bootstrap_form_builder/form_builder.rb
Instance Method Summary collapse
- #&(other) ⇒ Object
- #+(*args) ⇒ Object
- #-(*args) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(*args) ⇒ StringList
constructor
A new instance of StringList.
- #normalize! ⇒ Object
- #sort(*args) ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ StringList
Returns a new instance of StringList.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 3 def initialize(*args) super() args.each do |arg| if arg.is_a?(Array) concat(arg) else concat(Array((arg || '').to_s.split)) end end end |
Instance Method Details
#&(other) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 19 def &(other) case other when String StringList.new(super(other.split.flatten.compact.uniq)) else StringList.new(super) end end |
#+(*args) ⇒ Object
28 29 30 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 28 def +(*args) StringList.new(super(Array(args))) end |
#-(*args) ⇒ Object
32 33 34 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 32 def -(*args) StringList.new(super(Array(args))) end |
#==(other) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 36 def ==(other) case other when StringList, Array to_a.sort == normalize_array(other.to_a).sort else to_s == other.to_s end end |
#normalize! ⇒ Object
53 54 55 56 57 58 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 53 def normalize! flatten! compact! uniq! self end |
#sort(*args) ⇒ Object
15 16 17 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 15 def sort(*args) StringList.new(super) end |
#to_a ⇒ Object
45 46 47 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 45 def to_a normalize_array(super) end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/bootstrap_form_builder/form_builder.rb', line 49 def to_s to_a.join(' ') end |