Class: CTioga2::Graphics::Styles::CurveStyleFactory::CurveStyleFactoryParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/ctioga2/graphics/styles/factory.rb

Overview

A private class that defines a parameter for the Factory

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, sets, description, short_option = nil, disable_cmds = false) ⇒ CurveStyleFactoryParameter

Creates a new CurveStyleFactoryParameter object.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ctioga2/graphics/styles/factory.rb', line 62

def initialize(name, type, sets, description, 
               short_option = nil, disable_cmds = false)
  @name = name
  @type = Commands::CommandType.get_type(type)
  @sets = sets
  @description = description
  @short_option = short_option
  @disable_commands = disable_cmds
  
  ## \todo it is not very satisfying to mix CommandTypes and
  # MetaBuilder::Type on the same level.
  if @sets
    @sets_type = 
      MetaBuilder::Type.get_type({
                                   :type => :set,
                                   :subtype => @type.type,
                                   :shortcuts => @sets
                                 })
  end
end

Instance Attribute Details

#descriptionObject

The description of the parameter.



46
47
48
# File 'lib/ctioga2/graphics/styles/factory.rb', line 46

def description
  @description
end

#disable_commandsObject

If this attribute is on, then CurveStyleFactory will not generate commands for this parameter, only the option.



58
59
60
# File 'lib/ctioga2/graphics/styles/factory.rb', line 58

def disable_commands
  @disable_commands
end

#nameObject

The code-like name of the parameter



36
37
38
# File 'lib/ctioga2/graphics/styles/factory.rb', line 36

def name
  @name
end

#setsObject

The pre-defined sets available to use with that parameter. It is a hash.



43
44
45
# File 'lib/ctioga2/graphics/styles/factory.rb', line 43

def sets
  @sets
end

#sets_typeObject

The MetaBuilder::Type object that can convert a String to an Array suitable for use with CircularArray.



54
55
56
# File 'lib/ctioga2/graphics/styles/factory.rb', line 54

def sets_type
  @sets_type
end

#short_optionObject

The short option for setting the parameter directly from the command-line.



50
51
52
# File 'lib/ctioga2/graphics/styles/factory.rb', line 50

def short_option
  @short_option
end

#typeObject

The Commands::CommandType of the parameter



39
40
41
# File 'lib/ctioga2/graphics/styles/factory.rb', line 39

def type
  @type
end

Instance Method Details

#default_setObject

Returns a suitable default set for the given object.



84
85
86
87
88
89
90
91
92
93
# File 'lib/ctioga2/graphics/styles/factory.rb', line 84

def default_set
  return nil unless @sets
  if @sets.key? 'default'
    return @sets['default']
  else
    @sets.each do |k,v|
      return v
    end
  end
end