Class: Icalendar::Values::Array
- Inherits:
-
Icalendar::Value
- Object
- SimpleDelegator
- Icalendar::Value
- Icalendar::Values::Array
- Defined in:
- lib/icalendar/values/array.rb
Instance Attribute Summary collapse
-
#value_delimiter ⇒ Object
readonly
Returns the value of attribute value_delimiter.
Attributes inherited from Icalendar::Value
Instance Method Summary collapse
-
#initialize(value, klass, params = {}, options = {}) ⇒ Array
constructor
A new instance of Array.
- #params_ical ⇒ Object
- #valid? ⇒ Boolean
- #value_ical ⇒ Object
- #value_type ⇒ Object
Methods inherited from Icalendar::Value
#ical_param, #to_ical, #value, value_type
Constructor Details
#initialize(value, klass, params = {}, options = {}) ⇒ Array
Returns a new instance of Array.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/icalendar/values/array.rb', line 8 def initialize(value, klass, params = {}, = {}) @value_delimiter = [:delimiter] || ',' mapped = if value.is_a? ::Array value.map do |v| if v.is_a? Icalendar::Values::Array Icalendar::Values::Array.new v.value, klass, v.ical_params, delimiter: v.value_delimiter elsif v.is_a? ::Array Icalendar::Values::Array.new v, klass, params, delimiter: value_delimiter elsif v.is_a? Icalendar::Value v else klass.new v, params end end else [klass.new(value, params)] end super mapped, params end |
Instance Attribute Details
#value_delimiter ⇒ Object (readonly)
Returns the value of attribute value_delimiter.
6 7 8 |
# File 'lib/icalendar/values/array.rb', line 6 def value_delimiter @value_delimiter end |
Instance Method Details
#params_ical ⇒ Object
28 29 30 31 32 33 |
# File 'lib/icalendar/values/array.rb', line 28 def params_ical value.each do |v| ical_params.merge! v.ical_params end super end |
#valid? ⇒ Boolean
41 42 43 44 |
# File 'lib/icalendar/values/array.rb', line 41 def valid? klass = value.first.class !value.all? { |v| v.class == klass } end |
#value_ical ⇒ Object
35 36 37 38 39 |
# File 'lib/icalendar/values/array.rb', line 35 def value_ical value.map do |v| v.value_ical end.join value_delimiter end |
#value_type ⇒ Object
46 47 48 |
# File 'lib/icalendar/values/array.rb', line 46 def value_type value.first.value_type end |