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.



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

def initialize(name, type, sets, description, 
               short_option = nil, disable_cmds = false)
  @name = name
  @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.



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

def description
  @description
end

#disable_commandsObject

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



56
57
58
# File 'lib/ctioga2/graphics/styles/factory.rb', line 56

def disable_commands
  @disable_commands
end

#nameObject

The code-like name of the parameter



34
35
36
# File 'lib/ctioga2/graphics/styles/factory.rb', line 34

def name
  @name
end

#setsObject

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



41
42
43
# File 'lib/ctioga2/graphics/styles/factory.rb', line 41

def sets
  @sets
end

#sets_typeObject

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



52
53
54
# File 'lib/ctioga2/graphics/styles/factory.rb', line 52

def sets_type
  @sets_type
end

#short_optionObject

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



48
49
50
# File 'lib/ctioga2/graphics/styles/factory.rb', line 48

def short_option
  @short_option
end

#typeObject

The Commands::CommandType of the parameter



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

def type
  @type
end

Instance Method Details

#default_setObject

Returns a suitable default set for the given object.



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

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