Class: Peanuts::Converter::Convert_list
- Inherits:
-
Peanuts::Converter
- Object
- Peanuts::Converter
- Peanuts::Converter::Convert_list
- Defined in:
- lib/peanuts/converters.rb
Overview
An XSD whitespace-separated list.
- Specifier
-
:list, :item_type => simple type specifier
- Alternative specifier
-
[simple type specifier]
- Ruby type
-
Array
ofsimple type
Options
All options will be passed to the underlying type converter.
Instance Method Summary collapse
- #from_xml(string) ⇒ Object
-
#initialize(options) ⇒ Convert_list
constructor
A new instance of Convert_list.
- #to_xml(items) ⇒ Object
Methods inherited from Peanuts::Converter
create, create!, lookup, lookup!
Constructor Details
#initialize(options) ⇒ Convert_list
Returns a new instance of Convert_list.
219 220 221 222 |
# File 'lib/peanuts/converters.rb', line 219 def initialize() @item_type = [:item_type] || :string @item_converter = Converter.create!(@item_type, ) end |
Instance Method Details
#from_xml(string) ⇒ Object
228 229 230 |
# File 'lib/peanuts/converters.rb', line 228 def from_xml(string) string && string.split.map! {|x| @item_converter.from_xml(x)} end |
#to_xml(items) ⇒ Object
224 225 226 |
# File 'lib/peanuts/converters.rb', line 224 def to_xml(items) items && items.map {|x| @item_converter.to_xml(x) } * ' ' end |