Class: Icalendar::Values::Helpers::Array
- Inherits:
-
Icalendar::Value
- Object
- SimpleDelegator
- Icalendar::Value
- Icalendar::Values::Helpers::Array
- Defined in:
- lib/icalendar/values/helpers/array.rb
Constant Summary
Constants inherited from Icalendar::Value
Icalendar::Value::VALUE_TYPE_GSUB_REGEX_1, Icalendar::Value::VALUE_TYPE_GSUB_REGEX_2
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.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/icalendar/values/helpers/array.rb', line 11 def initialize(value, klass, params = {}, = {}) @value_delimiter = [:delimiter] || ',' mapped = if value.is_a? ::Array value.map do |v| if v.is_a? Icalendar::Values::Helpers::Array Icalendar::Values::Helpers::Array.new v.value, klass, v.ical_params, delimiter: v.value_delimiter elsif v.is_a? ::Array Icalendar::Values::Helpers::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 end |
Instance Attribute Details
#value_delimiter ⇒ Object (readonly)
Returns the value of attribute value_delimiter.
9 10 11 |
# File 'lib/icalendar/values/helpers/array.rb', line 9 def value_delimiter @value_delimiter end |
Instance Method Details
#params_ical ⇒ Object
31 32 33 34 35 36 |
# File 'lib/icalendar/values/helpers/array.rb', line 31 def params_ical value.each do |v| ical_params.merge! v.ical_params end super end |
#valid? ⇒ Boolean
44 45 46 47 |
# File 'lib/icalendar/values/helpers/array.rb', line 44 def valid? klass = value.first.class !value.all? { |v| v.class == klass } end |
#value_ical ⇒ Object
38 39 40 41 42 |
# File 'lib/icalendar/values/helpers/array.rb', line 38 def value_ical value.map do |v| v.value_ical end.join value_delimiter end |
#value_type ⇒ Object
49 50 51 |
# File 'lib/icalendar/values/helpers/array.rb', line 49 def value_type value.first.value_type end |