Class: Wicket::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/wicket/command.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cursor_startObject (readonly)

Returns the value of attribute cursor_start.



3
4
5
# File 'lib/wicket/command.rb', line 3

def cursor_start
  @cursor_start
end

#xObject (readonly)

Returns the value of attribute x.



3
4
5
# File 'lib/wicket/command.rb', line 3

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



3
4
5
# File 'lib/wicket/command.rb', line 3

def y
  @y
end

Class Method Details

.from_code(code, arg_string, subpath, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/wicket/command.rb', line 6

def from_code(code,arg_string,subpath,opts={})
  command_class = Commands.const_get(code.upcase) # get the class which handles this code
  absolute = (code.upcase == code) # is it uppercase?
  cursor_start = subpath.cursor_end # get the current position of the cursor
  args = arg_string.to_s.scan(/(?:\-\s*)?\d+(?:\.\d+)?/).flatten # parse out the numerical arguments
  if !args.empty?
    set_scale!(args,opts)
    generate_commands(args,command_class,absolute,cursor_start,subpath,opts)
  else # Must be a Z command
    [command_class.new(absolute,cursor_start,subpath,opts)]
  end
end

Instance Method Details

#absolute_xObject



37
38
39
# File 'lib/wicket/command.rb', line 37

def absolute_x
  @absolute ? x : cursor_start.x + ( @x || 0 )
end

#absolute_yObject



41
42
43
# File 'lib/wicket/command.rb', line 41

def absolute_y
  @absolute ? y : cursor_start.y + ( @y || 0 )
end

#argumentsObject



59
60
61
# File 'lib/wicket/command.rb', line 59

def arguments
  self.class::ARG_LIST.each_with_object({},&arg_maker)
end

#cursor_endObject



45
46
47
# File 'lib/wicket/command.rb', line 45

def cursor_end
  Coordinate.new(absolute_x,absolute_y)
end

#subpath=(subpath) ⇒ Object



33
34
35
# File 'lib/wicket/command.rb', line 33

def subpath=(subpath)
  @subpath = subpath
end

#to_svg(opts = {}) ⇒ Object



54
55
56
57
# File 'lib/wicket/command.rb', line 54

def to_svg(opts={})
  o = @opts.merge(opts)
  [letter,cursor_end.to_svg(o)].join("")
end

#to_wkt(opts = {}) ⇒ Object



49
50
51
52
# File 'lib/wicket/command.rb', line 49

def to_wkt(opts={})
  o = @opts.merge(opts)
  cursor_end.to_wkt(o)
end