Class: CellGlobalId

Inherits:
Object
  • Object
show all
Defined in:
lib/gsm_tools/cell_global_id.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ CellGlobalId

Returns a new instance of CellGlobalId.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gsm_tools/cell_global_id.rb', line 5

def initialize(str)
  @raw_hex_value = str.gsub(/.{2}/, '\0 ').split
  octet_1 = @raw_hex_value[0].hex.to_s(2).rjust(8, "0")
  octet_2 = @raw_hex_value[1].hex.to_s(2).rjust(8, "0")
  octet_3 = @raw_hex_value[2].hex.to_s(2).rjust(8, "0")

  @mcc = octet_1[4,4].to_i(2).to_s
  @mcc << octet_1[0,4].to_i(2).to_s
  @mcc << octet_2[4,4].to_i(2).to_s
  @mcc = @mcc.to_i.to_s

  @mnc = octet_3[4,4].to_i(2).to_s
  @mnc << octet_3[0,4].to_i(2).to_s
  @mnc << ""
  @mnc << octet_2[0,4].to_i(2).to_s unless octet_2[0,4].match(/1111/)
  @mnc = @mnc.to_i.to_s

  @lac = @raw_hex_value[3] + @raw_hex_value[4]
  @cell_id = @raw_hex_value[5] + @raw_hex_value[6]
end

Instance Attribute Details

#cell_idObject (readonly)

Returns the value of attribute cell_id.



3
4
5
# File 'lib/gsm_tools/cell_global_id.rb', line 3

def cell_id
  @cell_id
end

#lacObject (readonly)

Returns the value of attribute lac.



3
4
5
# File 'lib/gsm_tools/cell_global_id.rb', line 3

def lac
  @lac
end

#mccObject (readonly)

Returns the value of attribute mcc.



3
4
5
# File 'lib/gsm_tools/cell_global_id.rb', line 3

def mcc
  @mcc
end

#mncObject (readonly)

Returns the value of attribute mnc.



3
4
5
# File 'lib/gsm_tools/cell_global_id.rb', line 3

def mnc
  @mnc
end

#raw_hex_valueObject (readonly)

Returns the value of attribute raw_hex_value.



3
4
5
# File 'lib/gsm_tools/cell_global_id.rb', line 3

def raw_hex_value
  @raw_hex_value
end