Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/tcl/ruby/string.rb

Instance Method Summary collapse

Instance Method Details

#brace?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/tcl/ruby/string.rb', line 2

def brace?
  @brace ||= self[0] == '{'
end

#bracket?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/tcl/ruby/string.rb', line 6

def bracket?
  @bracket ||= self[0] == '['
end

#initObject



36
37
38
# File 'lib/tcl/ruby/string.rb', line 36

def init
  @brace = @bracket = @quote = nil
end

#parenthesis?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/tcl/ruby/string.rb', line 14

def parenthesis?
  brace? || bracket? || quote?
end

#quote?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/tcl/ruby/string.rb', line 10

def quote?
  @quote ||= self[0] == '"'
end

#to_tcl_listObject



28
29
30
31
32
33
34
# File 'lib/tcl/ruby/string.rb', line 28

def to_tcl_list
  if self == '' || match(/\s/)
    "{#{self}}"
  else
    self
  end
end

#to_tcl_stringObject



18
19
20
21
22
23
24
25
26
# File 'lib/tcl/ruby/string.rb', line 18

def to_tcl_string
  if parenthesis?
    if (brace? && self[-1] == '}') || (quote? && self[-1] == '"')
      b = self[1..-2]
      clear << b
    end
  end
  self
end