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 = {}, context = {}) ⇒ 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 = {}, context = {}) ⇒ 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 30 |
# File 'lib/icalendar/values/helpers/array.rb', line 11 def initialize(value, klass, params = {}, context = {}) context = Icalendar::DowncasedHash(context) @value_delimiter = context['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, context.merge(delimiter: v.value_delimiter) elsif v.is_a? ::Array Icalendar::Values::Helpers::Array.new v, klass, params, context.merge(delimiter: value_delimiter) elsif v.is_a? Icalendar::Value v else klass.new v, params, context end end else [klass.new(value, params, context)] 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
32 33 34 35 36 37 |
# File 'lib/icalendar/values/helpers/array.rb', line 32 def params_ical value.each do |v| ical_params.merge! v.ical_params end super end |
#valid? ⇒ Boolean
45 46 47 48 |
# File 'lib/icalendar/values/helpers/array.rb', line 45 def valid? klass = value.first.class !value.all? { |v| v.class == klass } end |
#value_ical ⇒ Object
39 40 41 42 43 |
# File 'lib/icalendar/values/helpers/array.rb', line 39 def value_ical value.map do |v| v.value_ical end.join value_delimiter end |
#value_type ⇒ Object
50 51 52 |
# File 'lib/icalendar/values/helpers/array.rb', line 50 def value_type value.first.value_type end |