Class: RBarcode::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rbarcode/base.rb

Direct Known Subclasses

Code39, Postnet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rbarcode/base.rb', line 17

def initialize(options = {})
  prefs = File.expand_path(options[:prefs] || "~/.rbarcode.yml")
  YAML.load(File.open(prefs)).each {|pref, value| eval("@#{pref} = #{value.inspect}")} if File.exists?(prefs)

  @required = Array.new

  # include all provided data
  options.each do |method, value|
    instance_variable_set("@#{method}", value)
  end
end

Instance Attribute Details

#requiredObject (readonly)

Returns the value of attribute required.



13
14
15
# File 'lib/rbarcode/base.rb', line 13

def required
  @required
end

#text=(value) ⇒ Object (writeonly)

Sets the attribute text

Parameters:

  • value

    the value to set the attribute text to.



15
16
17
# File 'lib/rbarcode/base.rb', line 15

def text=(value)
  @text = value
end

Instance Method Details

#code39Object

Initializes an instance of RBarcode::Code39 with the same instance variables as the base object



30
31
32
# File 'lib/rbarcode/base.rb', line 30

def code39
  RBarcode::Code39.new prepare_vars
end

#postnetObject

Initializes an instance of RBarcode::Postnet with the same instance variables as the base object



35
36
37
# File 'lib/rbarcode/base.rb', line 35

def postnet
  RBarcode::Postnet.new prepare_vars
end