class CultomePlayer::Objects::Parameter

Public Class Methods

new(data) click to toggle source

Initialize a parameter with the data provided.

@param data [Hash] Contains the keys :criteria, :value, :type

# File lib/cultome_player/objects/parameter.rb, line 9
def initialize(data)
  @data = data
end

Public Instance Methods

criteria() click to toggle source

Get the criteria asocciated with the parameter, if any.

# File lib/cultome_player/objects/parameter.rb, line 14
def criteria
  return nil if @data[:criteria].nil?
  @data[:criteria].to_sym
end
raw_value() click to toggle source

Return the value as the user input typed (no conversions).

@return [String] The values of the parameter as the user typed.

# File lib/cultome_player/objects/parameter.rb, line 32
def raw_value
  @data[:value]
end
to_s() click to toggle source
# File lib/cultome_player/objects/parameter.rb, line 43
def to_s
  return case @data[:type]
    when :literal then @data[:value]
    when :criteria then "#{@data[:criteria]}:#{@data[:value]}"
    when :number then @data[:value]
    when :object then "@#{@data[:value]}"
    when :boolean then @data[:value]
    when :path then @data[:value]
    when :bubble then @data[:value]
    else value
  end
end
type() click to toggle source

Returns the type associated with the parameter.

@return [Symbol] The type of the parameter.

# File lib/cultome_player/objects/parameter.rb, line 39
def type
  @data[:type]
end
value() click to toggle source

Returns the value associated with the parameter in its appropiated type.

@return [Object] The value of the parameter.

# File lib/cultome_player/objects/parameter.rb, line 22
def value
  return is_true_value?(@data[:value]) if @data[:type] == :boolean
  return @data[:value].to_i if @data[:type] == :number
  return @data[:value].to_sym if @data[:type] == :object
  return raw_value
end