Class: Dot::Id

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(string) ⇒ Id

Returns a new instance of Id.

Raises:

  • (ArgumentError)


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

#escapedObject



14
15
16
17
18
# File 'lib/dot/id.rb', line 14

def escaped
  @string.gsub!("\"", "\\\"")
  @string.gsub!("\'", "\\\'")
  @string
end

#to_dotObject



20
21
22
# File 'lib/dot/id.rb', line 20

def to_dot
  "\"#{escaped}\""
end