class Dentaku::AST::Duration::Value
Attributes
unit[R]
value[R]
Public Class Methods
new(value, unit)
click to toggle source
# File lib/dentaku/ast/functions/duration.rb, line 17 def initialize(value, unit) @value = value @unit = validate_unit(unit) end
Public Instance Methods
validate_unit(unit)
click to toggle source
# File lib/dentaku/ast/functions/duration.rb, line 22 def validate_unit(unit) case unit.downcase when /years?/ then :year when /months?/ then :month when /days?/ then :day else raise Dentaku::ArgumentError.for(:incompatible_type, value: unit, for: Duration), "'#{unit || unit.class}' is not a valid duration unit" end end