Sha256: 9f2eb6c08d3082970cbcf8e67263522a8feab93e3e867fb79ddd3e24486348e6

Contents?: true

Size: 1.04 KB

Versions: 34

Compression:

Stored size: 1.04 KB

Contents

module Fig; end

class Fig::TokenizedString
  def initialize(segments, single_quoted, metacharacters)
    @segments       = segments
    @single_quoted  = single_quoted
    @metacharacters = metacharacters

    return
  end

  def single_quoted?()
    return @single_quoted
  end

  def can_be_single_quoted?()
    return true if single_quoted?
    return @segments.all? {|segment| segment.type.nil?}
  end

  def to_expanded_string(&block)
    return (
      @segments.collect { |segment| segment.to_expanded_string(&block) }
    ).join ''
  end

  def to_escaped_string()
    return ( @segments.collect {|segment| segment.to_escaped_string} ).join ''
  end

  def to_single_quoted_string()
    return to_escaped_string if single_quoted?

    return (
      @segments.collect {|segment| segment.to_single_quoted_string}
    ).join ''
  end

  def to_double_quotable_string()
    return to_escaped_string if ! single_quoted?

    return (
      @segments.collect {
        |segment| segment.to_double_quotable_string @metacharacters
      }
    ).join ''
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
fig-1.23.0 lib/fig/tokenized_string.rb
fig-1.22.1.beta.1 lib/fig/tokenized_string.rb
fig-1.22.0 lib/fig/tokenized_string.rb
fig-1.21.1.beta.2 lib/fig/tokenized_string.rb
fig-1.21.1.beta.1 lib/fig/tokenized_string.rb
fig-1.21.0 lib/fig/tokenized_string.rb
fig-1.20.1.beta.1 lib/fig/tokenized_string.rb
fig-1.20.0 lib/fig/tokenized_string.rb
fig-1.19.0 lib/fig/tokenized_string.rb
fig-1.18.0 lib/fig/tokenized_string.rb
fig-1.17.0 lib/fig/tokenized_string.rb
fig-1.16.1.beta.1 lib/fig/tokenized_string.rb
fig-1.16.0 lib/fig/tokenized_string.rb
fig-1.15.1.beta.2 lib/fig/tokenized_string.rb
fig-1.15.1.beta.1 lib/fig/tokenized_string.rb
fig-1.15.0 lib/fig/tokenized_string.rb
fig-1.14.0 lib/fig/tokenized_string.rb
fig-1.13.0 lib/fig/tokenized_string.rb
fig-1.12.0 lib/fig/tokenized_string.rb
fig-1.11.0 lib/fig/tokenized_string.rb