Class: VCDOM::XPath::Internal::StringValue
- Inherits:
-
AbstractValue
- Object
- AbstractValue
- VCDOM::XPath::Internal::StringValue
- Defined in:
- lib/vcdom/xpath/internal/value.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(val) ⇒ StringValue
constructor
A new instance of StringValue.
-
#to_boolean_value ⇒ Object
文字列は、その長さが非ゼロである場合に、かつ非ゼロである場合にのみ、真である。.
-
#to_number_value ⇒ Object
StringValue を NumberValue に変換する オプションの空白にオプションの負号 1 個が続き, [0-9](“.” [0-9]*)? | “.” [0-9]+ が続いて空白が続いたものからなる文字列は, その文字列が表す数学的値に (IEEE 754 最近接値丸めルールに従い) 最も近い IEEE 754 数値に変換される.
- #to_string_value ⇒ Object
- #value_type ⇒ Object
Methods inherited from AbstractValue
#%, #*, #+, #-, #-@, #/, #<, #<=, #<=>, #==, #>, #>=, #is_command?, #is_expr?, #is_value?, #neq?, #to_s, #|
Constructor Details
#initialize(val) ⇒ StringValue
Returns a new instance of StringValue.
140 141 142 |
# File 'lib/vcdom/xpath/internal/value.rb', line 140 def initialize( val ) @value = val.to_s end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
167 168 169 |
# File 'lib/vcdom/xpath/internal/value.rb', line 167 def value @value end |
Instance Method Details
#to_boolean_value ⇒ Object
文字列は、その長さが非ゼロである場合に、かつ非ゼロである場合にのみ、真である。
163 164 165 |
# File 'lib/vcdom/xpath/internal/value.rb', line 163 def to_boolean_value() @value.length != 0 ? BooleanValue.true : BooleanValue.false end |
#to_number_value ⇒ Object
StringValue を NumberValue に変換する オプションの空白にオプションの負号 1 個が続き, [0-9](“.” [0-9]*)? | “.” [0-9]+ が続いて空白が続いたものからなる文字列は, その文字列が表す数学的値に (IEEE 754 最近接値丸めルールに従い) 最も近い IEEE 754 数値に変換される. その他の文字列はどれも NaN に変換される.
151 152 153 154 155 156 157 158 159 160 |
# File 'lib/vcdom/xpath/internal/value.rb', line 151 def to_number_value() str = @value.gsub( /[\x20\x09\x0A\x0D]/u, "" ) if str =~ /\A\-?(?:\d+(?:\.\d*)?|\.\d+)\Z/ then # NaN return NumberValue.new( str.to_f ) else # NaN return NumberValue.new( 0.0 / 0.0 ) end end |
#to_string_value ⇒ Object
143 144 145 |
# File 'lib/vcdom/xpath/internal/value.rb', line 143 def to_string_value() self end |
#value_type ⇒ Object
168 |
# File 'lib/vcdom/xpath/internal/value.rb', line 168 def value_type; :string end |