Class: Peanuts::Converter::Convert_list
- Inherits:
-
Object
- Object
- 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
Constructor Details
#initialize(options) ⇒ Convert_list
Returns a new instance of Convert_list.
210 211 212 213 |
# File 'lib/peanuts/converters.rb', line 210 def initialize() @item_type = [:item_type] || :string @item_converter = Converter.create!(@item_type, ) end |
Instance Method Details
#from_xml(string) ⇒ Object
219 220 221 |
# File 'lib/peanuts/converters.rb', line 219 def from_xml(string) string && string.split.map! {|x| @item_converter.from_xml(x)} end |
#to_xml(items) ⇒ Object
215 216 217 |
# File 'lib/peanuts/converters.rb', line 215 def to_xml(items) items && items.map {|x| @item_converter.to_xml(x) } * ' ' end |