Class: Dot::Id
- Inherits:
-
Object
- Object
- Dot::Id
- Defined in:
- lib/dot/id.rb
Overview
Any string of alphabetic ([a-zA-Z\200-\377]) characters, underscores ('_') or digits ([0-9]), not beginning with a digit; a numeral [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? ); any double-quoted string ("...") possibly containing escaped quotes ('"); an HTML string (<...>).
Instance Method Summary collapse
- #escaped ⇒ Object
-
#initialize(string) ⇒ Id
constructor
A new instance of Id.
- #to_dot ⇒ Object
Constructor Details
#initialize(string) ⇒ Id
Returns a new instance of Id.
9 10 11 12 |
# File 'lib/dot/id.rb', line 9 def initialize(string) @string = string.to_s raise ArgumentError if @string.empty? end |
Instance Method Details
#escaped ⇒ Object
14 15 16 17 18 |
# File 'lib/dot/id.rb', line 14 def escaped @string.gsub!("\"", "\\\"") @string.gsub!("\'", "\\\'") @string end |
#to_dot ⇒ Object
20 21 22 |
# File 'lib/dot/id.rb', line 20 def to_dot "\"#{escaped}\"" end |