Class: ZBar::Symbol

Inherits:
Object
  • Object
show all
Defined in:
lib/zbar/symbol.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol = nil) ⇒ Symbol

Returns a new instance of Symbol.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/zbar/symbol.rb', line 6

def initialize(symbol=nil)
  if symbol
    type = ZBar.zbar_symbol_get_type(symbol)
    @symbology = ZBar.zbar_get_symbol_name(type)
    @data = ZBar.zbar_symbol_get_data(symbol)
    @addon = ZBar.zbar_get_addon_name(type)
    @quality = ZBar.zbar_symbol_get_quality(symbol)

    @location = []
    point_count = ZBar.zbar_symbol_get_loc_size(symbol)
    i = 0
    while i < point_count
      @location << [ZBar.zbar_symbol_get_loc_x(symbol, i), ZBar.zbar_symbol_get_loc_y(symbol, i)]
      i += 1
    end
  end
end

Instance Attribute Details

#addonObject (readonly)

Returns the value of attribute addon.



4
5
6
# File 'lib/zbar/symbol.rb', line 4

def addon
  @addon
end

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/zbar/symbol.rb', line 4

def data
  @data
end

#locationObject (readonly)

Returns the value of attribute location.



4
5
6
# File 'lib/zbar/symbol.rb', line 4

def location
  @location
end

#qualityObject (readonly)

Returns the value of attribute quality.



4
5
6
# File 'lib/zbar/symbol.rb', line 4

def quality
  @quality
end

#symbologyObject (readonly)

Returns the value of attribute symbology.



4
5
6
# File 'lib/zbar/symbol.rb', line 4

def symbology
  @symbology
end

Instance Method Details

#==(symbol) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/zbar/symbol.rb', line 24

def ==(symbol)
  return false unless symbol.kind_of?(Symbol)
  
  (
    self.symbology == symbol.symbology &&
    self.data == symbol.data &&
    self.addon == symbol.addon &&
    self.quality == symbol.quality &&
    self.location == symbol.location
  )
end