Object
# File lib/origami/graphics/instruction.rb, line 75 def get_operands(operator) @insns[operator][:operands] end
# File lib/origami/graphics/instruction.rb, line 71 def get_render_proc(operator) @insns[operator][:render] end
# File lib/origami/graphics/instruction.rb, line 67 def has_op?(operator) @insns.has_key? operator end
# File lib/origami/graphics/instruction.rb, line 61 def insn(operator, *operands, &render_proc) @insns[operator] = {} @insns[operator][:operands] = operands @insns[operator][:render] = render_proc || lambda{} end
# File lib/origami/graphics/instruction.rb, line 36 def initialize(operator, *operands) @operator = operator @operands = operands.map!{|arg| arg.is_a?(Origami::Object) ? arg.value : arg} if self.class.has_op?(operator) opdef = self.class.get_operands(operator) if not opdef.include?('*') and opdef.size != operands.size raise InvalidPDFInstructionError, "Numbers of operands mismatch for #{operator}: #{operands.inspect}" end end end
# File lib/origami/graphics/instruction.rb, line 79 def parse(stream) operands = [] while type = Object.typeof(stream, true) operands.push type.parse(stream) end if not stream.eos? if stream.scan(@@regexp).nil? raise InvalidPDFInstructionError, "Operator: #{(stream.peek(10) + '...').inspect}" end operator = stream[1] PDF::Instruction.new(operator, *operands) else if not operands.empty? raise InvalidPDFInstructionError, "No operator given for operands: #{operands.join}" end end end
Generated with the Darkfish Rdoc Generator 2.