Sha256: 2883f20dc2c144ac65e5f79357f110d8fdadacf3e44799cff03273040394a3d3

Contents?: true

Size: 1.99 KB

Versions: 5

Compression:

Stored size: 1.99 KB

Contents

class Rtml::HighLevel::ManagedVariable
  attr_reader :name
  
  def initialize(name)
    @name = name
  end

  # Returns the TML necessary to test whether this variable's value is equal to the specified argument's value.
  def ==(other)
    op(:equal, other)
  end

  # Returns the TML necessary to test whether this variable's value is not equal to the specified argument's value.
  def not_equal(other)
    op(:not_equal, other)
  end
  alias not_equal_to not_equal

  # Returns the TML necessary to test whether this variable's value is less than the specified argument's value.
  def <(other)
    op(:less, other)
  end

  # Returns the TML necessary to test whether this variable's value is greater than the specified argument's value.
  def >(other)
    op(:greater, other)
  end

  # Returns the TML necessary to test whether this variable's value is less than or equal to the specified value.
  def <=(other)
    op(:less_or_equal, other)
  end

  # Returns the TML necessary to test whether this variable's value is greater than or equal to the specified value.
  def >=(other)
    op(:greater_or_equal, other)
  end

  # Returns the TML necessary to add or concatenate the specified value with this one.
  def +(other) op(:plus, other) end

  # Returns the TML necessary to subtract the specified value from this one.
  def -(other) op(:minus, other) end

  # Returns the TML necessary to retrieve an item from the list with the specified index.
  def item(other)
    op(:item, other)
  end
  alias [] item

  # Returns the TML necessary to retrieve the number of items in the list.
  def number
    op(:number, nil)
  end
  alias length number
  alias size number

  # Returns the TML necessary to format this variable using the specified format.
  def format(other)
    op(:format, other)
  end

  private
  def op(which, other)
    which = which.to_s
    if other.kind_of?(Rtml::HighLevel::ManagedVariable)
      ["tmlvar:#{name}", which, "tmlvar:#{other.name}"]
    else
      ["tmlvar:#{name}", which, other]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rtml-2.0.4 lib/rtml/high_level/managed_variable.rb
rtml-2.0.3 lib/rtml/high_level/managed_variable.rb
rtml-2.0.2 lib/rtml/high_level/managed_variable.rb
rtml-2.0.1 lib/rtml/high_level/managed_variable.rb
rtml-2.0.0.alpha.1 lib/rtml/high_level/managed_variable.rb