class Fig::Statement

A statement within a package definition file (package.fig).

Constants

ENVIRONMENT_VARIABLE_NAME_REGEX

Attributes

column[R]
line[R]
source_description[R]

Public Class Methods

new(line_column, source_description) click to toggle source

This mess of getting these as a single array necessary is due to limitations of the “*” array splat operator in ruby v1.8.

# File lib/fig/statement.rb, line 31
def initialize(line_column, source_description)
  if line_column
    @line, @column = *line_column
  end

  @source_description = source_description
end
position_description(line, column, source_description) click to toggle source
# File lib/fig/statement.rb, line 11
def self.position_description(line, column, source_description)
  if not line or not column
    return '' if not source_description

    return " (#{source_description})"
  end

  description = " (line #{line}, column #{column}"
  if source_description
    description << ", #{source_description}"
  end
  description << ')'

  return description
end

Public Instance Methods

deparse_as_version(deparser) click to toggle source
# File lib/fig/statement.rb, line 52
def deparse_as_version(deparser)
  raise NotImplementedError.new(
    "#{__callee__}() not implemented on #{self.class}."
  )
end
is_asset?() click to toggle source
# File lib/fig/statement.rb, line 78
def is_asset?()
  return false
end
is_environment_variable?() click to toggle source
# File lib/fig/statement.rb, line 82
def is_environment_variable?()
  return false
end
minimum_grammar_for_emitting_input() click to toggle source

Returns a two element array containing the version and an explanation of why the version is necessary if the version is greater than 0.

# File lib/fig/statement.rb, line 60
def minimum_grammar_for_emitting_input()
  raise NotImplementedError.new(
    "#{__callee__}() not implemented on #{self.class}."
  )
end
minimum_grammar_for_publishing() click to toggle source

Returns a two element array containing the version and an explanation of why the version is necessary if the version is greater than 0.

# File lib/fig/statement.rb, line 68
def minimum_grammar_for_publishing()
  raise NotImplementedError.new(
    "#{__callee__}() not implemented on #{self.class}."
  )
end
position_string() click to toggle source

Returns a representation of the position of this statement, if the position is known, empty string otherwise. This is written with the idea that you can do something like “puts %Q<Found a statement%{statement.position_string()}.>” and get nice looking output regardless of whether the position is actually known or not.

# File lib/fig/statement.rb, line 91
def position_string
  return Fig::Statement.position_description(
    @line, @column, @source_description
  )
end
statement_type() click to toggle source

A name for this kind of Statement, usually a keyword for this statement as it appears in package definition files.

# File lib/fig/statement.rb, line 41
def statement_type()
  raise NotImplementedError.new(
    "#{__callee__}() not implemented on #{self.class}."
  )
end
urls() click to toggle source
# File lib/fig/statement.rb, line 74
def urls()
  return []
end
walk_statements(&block) click to toggle source

Block will receive a Statement.

# File lib/fig/statement.rb, line 48
def walk_statements(&block)
  return
end