Class: UR::Sab

Inherits:
Object
  • Object
show all
Defined in:
lib/ur/sab.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, count = nil) ⇒ Sab

Returns a new instance of Sab.



9
10
11
12
13
# File 'lib/ur/sab.rb', line 9

def initialize(code, count = nil)
  @code = code
  @text = UR::Sab::translate(code)
  @count = count
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



7
8
9
# File 'lib/ur/sab.rb', line 7

def code
  @code
end

#countObject (readonly)

Returns the value of attribute count.



7
8
9
# File 'lib/ur/sab.rb', line 7

def count
  @count
end

#textObject (readonly)

Returns the value of attribute text.



7
8
9
# File 'lib/ur/sab.rb', line 7

def text
  @text
end

Class Method Details

.translate(code) ⇒ Object



32
33
34
# File 'lib/ur/sab.rb', line 32

def self.translate(code)
  UR::SAB_CODES.has_key?(code) ? SAB_CODES[code] : false
end

Instance Method Details

#parentsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ur/sab.rb', line 15

def parents
  sab_parents = []

  if code
    tmp = ''
    parts = code.split('')

    parts.pop

    sab_parents = parts.map {|p|
      UR::Sab.new(tmp += p) unless p.match(/(\.|\:)/)
    }.compact
  end

  sab_parents
end