Class: Postsvg::Svg::PathData::Command

Inherits:
Struct
  • Object
show all
Defined in:
lib/postsvg/svg/path_data/command.rb

Overview

Single SVG path command. Opcode is upper-case (absolute) or lower-case (relative). args is the raw numeric arguments.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject

Returns the value of attribute args

Returns:

  • (Object)

    the current value of args



8
9
10
# File 'lib/postsvg/svg/path_data/command.rb', line 8

def args
  @args
end

#opcodeObject

Returns the value of attribute opcode

Returns:

  • (Object)

    the current value of opcode



8
9
10
# File 'lib/postsvg/svg/path_data/command.rb', line 8

def opcode
  @opcode
end

Instance Method Details

#absolute?Boolean

Returns:

  • (Boolean)


9
# File 'lib/postsvg/svg/path_data/command.rb', line 9

def absolute? = opcode == opcode.upcase

#arityObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/postsvg/svg/path_data/command.rb', line 13

def arity
  case opcode.upcase
  when "M", "L", "T" then 2
  when "H", "V" then 1
  when "C" then 6
  when "S", "Q" then 4
  when "A" then 7
  when "Z" then 0
  else 0
  end
end

#relative?Boolean

Returns:

  • (Boolean)


11
# File 'lib/postsvg/svg/path_data/command.rb', line 11

def relative? = opcode == opcode.downcase