Class: CultomePlayer::Objects::Parameter
- Inherits:
-
Object
- Object
- CultomePlayer::Objects::Parameter
- Includes:
- Utils
- Defined in:
- lib/cultome_player/objects/parameter.rb
Instance Method Summary collapse
-
#criteria ⇒ Object
Get the criteria asocciated with the parameter, if any.
-
#initialize(data) ⇒ Parameter
constructor
Initialize a parameter with the data provided.
-
#raw_value ⇒ String
Return the value as the user input typed (no conversions).
- #to_s ⇒ Object
-
#type ⇒ Symbol
Returns the type associated with the parameter.
-
#value ⇒ Object
Returns the value associated with the parameter in its appropiated type.
Methods included from Utils
#arrange_in_columns, #display, #display_over, #ensure_db_schema, #is_true_value?, #recreate_db_schema, #swallow_stdout, #to_display_list, #with_connection
Constructor Details
#initialize(data) ⇒ Parameter
Initialize a parameter with the data provided.
9 10 11 |
# File 'lib/cultome_player/objects/parameter.rb', line 9 def initialize(data) @data = data end |
Instance Method Details
#criteria ⇒ Object
Get the criteria asocciated with the parameter, if any.
14 15 16 17 |
# File 'lib/cultome_player/objects/parameter.rb', line 14 def criteria return nil if @data[:criteria].nil? @data[:criteria].to_sym end |
#raw_value ⇒ String
Return the value as the user input typed (no conversions).
32 33 34 |
# File 'lib/cultome_player/objects/parameter.rb', line 32 def raw_value @data[:value] end |
#to_s ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# 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 ⇒ Symbol
Returns the type associated with the parameter.
39 40 41 |
# File 'lib/cultome_player/objects/parameter.rb', line 39 def type @data[:type] end |
#value ⇒ Object
Returns the value associated with the parameter in its appropiated type.
22 23 24 25 26 27 |
# 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 |