Class: Icalendar2::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/icalendar2/value.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Value

Returns a new instance of Value.



20
21
22
23
24
# File 'lib/icalendar2/value.rb', line 20

def initialize(value)
  @valid = true
  @value = value
  validate
end

Class Attribute Details

.format_matcherObject (readonly)

Returns the value of attribute format_matcher.



4
5
6
# File 'lib/icalendar2/value.rb', line 4

def format_matcher
  @format_matcher
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/icalendar2/value.rb', line 7

def value
  @value
end

Class Method Details

.get_factory(value_sym) ⇒ Object



13
14
15
16
17
18
# File 'lib/icalendar2/value.rb', line 13

def self.get_factory(value_sym)
  # :foo => "Foo", :bar_baz => "BarBaz", etc.
  value_name = value_sym.to_s.split(/_/).map(&:capitalize).join('')
  value_class_name = "#{value_name}Value"
  Icalendar2.const_get(value_class_name) if Icalendar2.const_defined?(value_class_name)
end

.matches(matcher) ⇒ Object



9
10
11
# File 'lib/icalendar2/value.rb', line 9

def self.matches(matcher)
  @format_matcher = matcher
end

Instance Method Details

#to_sObject



30
31
32
# File 'lib/icalendar2/value.rb', line 30

def to_s
  value.to_s
end

#valid?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/icalendar2/value.rb', line 26

def valid?
  @valid
end