Class: Fig::TokenizedString
- Inherits:
-
Object
- Object
- Fig::TokenizedString
show all
- Defined in:
- lib/fig/tokenized_string.rb,
lib/fig/tokenized_string/token.rb,
lib/fig/tokenized_string/plain_segment.rb
Defined Under Namespace
Classes: PlainSegment, Token
Instance Method Summary
collapse
Constructor Details
#initialize(segments, single_quoted, metacharacters) ⇒ TokenizedString
Returns a new instance of TokenizedString.
4
5
6
7
8
9
10
|
# File 'lib/fig/tokenized_string.rb', line 4
def initialize(segments, single_quoted, metacharacters)
@segments = segments
@single_quoted = single_quoted
@metacharacters = metacharacters
return
end
|
Instance Method Details
#can_be_single_quoted? ⇒ Boolean
16
17
18
19
|
# File 'lib/fig/tokenized_string.rb', line 16
def can_be_single_quoted?()
return true if single_quoted?
return @segments.all? {|segment| segment.type.nil?}
end
|
#single_quoted? ⇒ Boolean
12
13
14
|
# File 'lib/fig/tokenized_string.rb', line 12
def single_quoted?()
return @single_quoted
end
|
#to_double_quotable_string ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/fig/tokenized_string.rb', line 39
def to_double_quotable_string()
return to_escaped_string if ! single_quoted?
return (
@segments.collect {
|segment| segment.to_double_quotable_string @metacharacters
}
).join ''
end
|
#to_escaped_string ⇒ Object
27
28
29
|
# File 'lib/fig/tokenized_string.rb', line 27
def to_escaped_string()
return ( @segments.collect {|segment| segment.to_escaped_string} ).join ''
end
|
#to_expanded_string(&block) ⇒ Object
21
22
23
24
25
|
# File 'lib/fig/tokenized_string.rb', line 21
def to_expanded_string(&block)
return (
@segments.collect { |segment| segment.to_expanded_string(&block) }
).join ''
end
|
#to_single_quoted_string ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/fig/tokenized_string.rb', line 31
def to_single_quoted_string()
return to_escaped_string if single_quoted?
return (
@segments.collect {|segment| segment.to_single_quoted_string}
).join ''
end
|