Class: UdatScalar
Overview
Class of UDAT objects holding scalar values (stored as a String).
Constant Summary
Constants inherited from Udat
Udat::ExampleDocument, Udat::KeepTag
Instance Attribute Summary collapse
-
#content ⇒ Object
Content of the scalar (a String).
Attributes inherited from Udat
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Returns true, if the (String representation of the) content is empty.
-
#encoded_content ⇒ Object
Returns the encoded form of the content as a string.
-
#initialize(tag, content) ⇒ UdatScalar
constructor
Creates a new Udat object with a given tag (which may be nil) and a given content, which is transformed to a string (via ‘to_s’).
-
#to_i ⇒ Object
Returns the content casted to an Integer.
-
#to_s ⇒ Object
Same as UdatScalar#content.
Methods inherited from Udat
#==, #collection?, #encode, #eql?, escape_string, #hash, #inspect, parse, read_from_stream, #scalar?, #to_udat, #write_to_stream
Constructor Details
#initialize(tag, content) ⇒ UdatScalar
Creates a new Udat object with a given tag (which may be nil) and a given content, which is transformed to a string (via ‘to_s’). It is not recommended to use this method. Use Object#to_udat instead.
920 921 922 923 |
# File 'lib/udat.rb', line 920 def initialize(tag, content) super tag self.content = content end |
Instance Attribute Details
#content ⇒ Object
Content of the scalar (a String).
926 927 928 |
# File 'lib/udat.rb', line 926 def content @content end |
Instance Method Details
#empty? ⇒ Boolean
Returns true, if the (String representation of the) content is empty.
942 943 944 |
# File 'lib/udat.rb', line 942 def empty? self.to_s.empty? end |
#encoded_content ⇒ Object
Returns the encoded form of the content as a string. In this case this is simply an escaped version of the String. This method is used by Udat#encode, which returns the complete encoding of the data (including the tag).
950 951 952 |
# File 'lib/udat.rb', line 950 def encoded_content escape_string(self.to_s) end |
#to_i ⇒ Object
Returns the content casted to an Integer.
937 938 939 |
# File 'lib/udat.rb', line 937 def to_i content.to_i end |
#to_s ⇒ Object
Same as UdatScalar#content.
933 934 935 |
# File 'lib/udat.rb', line 933 def to_s content end |