Class: Wicket::Command
- Inherits:
-
Object
- Object
- Wicket::Command
- Defined in:
- lib/wicket/command.rb
Direct Known Subclasses
Wicket::Commands::C, Wicket::Commands::H, Wicket::Commands::L, Wicket::Commands::M, Wicket::Commands::Q, Wicket::Commands::S, Wicket::Commands::T, Wicket::Commands::V, Wicket::Commands::Z
Instance Attribute Summary collapse
-
#cursor_start ⇒ Object
readonly
Returns the value of attribute cursor_start.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Class Method Summary collapse
Instance Method Summary collapse
- #absolute_x ⇒ Object
- #absolute_y ⇒ Object
- #arguments ⇒ Object
- #cursor_end ⇒ Object
- #subpath=(subpath) ⇒ Object
- #to_svg(opts = {}) ⇒ Object
- #to_wkt(opts = {}) ⇒ Object
Instance Attribute Details
#cursor_start ⇒ Object (readonly)
Returns the value of attribute cursor_start.
3 4 5 |
# File 'lib/wicket/command.rb', line 3 def cursor_start @cursor_start end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
3 4 5 |
# File 'lib/wicket/command.rb', line 3 def x @x end |
#y ⇒ Object (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_x ⇒ Object
37 38 39 |
# File 'lib/wicket/command.rb', line 37 def absolute_x @absolute ? x : cursor_start.x + ( @x || 0 ) end |
#absolute_y ⇒ Object
41 42 43 |
# File 'lib/wicket/command.rb', line 41 def absolute_y @absolute ? y : cursor_start.y + ( @y || 0 ) end |
#arguments ⇒ Object
59 60 61 |
# File 'lib/wicket/command.rb', line 59 def arguments self.class::ARG_LIST.each_with_object({},&arg_maker) end |
#cursor_end ⇒ Object
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 |