Class: Saxon::ItemType::LexicalStringConversion::DurationConversion

Inherits:
Object
  • Object
show all
Defined in:
lib/saxon/item_type/lexical_string_conversion.rb

Overview

Convert a value in seconds into an XDM Duration string

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ DurationConversion

Returns a new instance of DurationConversion.



131
132
133
# File 'lib/saxon/item_type/lexical_string_conversion.rb', line 131

def initialize(pattern)
  @pattern = pattern
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern.



129
130
131
# File 'lib/saxon/item_type/lexical_string_conversion.rb', line 129

def pattern
  @pattern
end

Instance Method Details

#call(value, item_type) ⇒ Object

Produce a lexical Duration string from a numeric Ruby value representing seconds



137
138
139
140
# File 'lib/saxon/item_type/lexical_string_conversion.rb', line 137

def call(value, item_type)
  return numeric(value) if Numeric === value
  LexicalStringConversion.validate(value, item_type, pattern)
end