Class: CellGlobalId
- Inherits:
-
Object
- Object
- CellGlobalId
- Defined in:
- lib/gsm_tools/cell_global_id.rb
Instance Attribute Summary collapse
-
#cell_id ⇒ Object
readonly
Returns the value of attribute cell_id.
-
#lac ⇒ Object
readonly
Returns the value of attribute lac.
-
#mcc ⇒ Object
readonly
Returns the value of attribute mcc.
-
#mnc ⇒ Object
readonly
Returns the value of attribute mnc.
-
#raw_hex_value ⇒ Object
readonly
Returns the value of attribute raw_hex_value.
Instance Method Summary collapse
-
#initialize(str) ⇒ CellGlobalId
constructor
A new instance of CellGlobalId.
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_id ⇒ Object (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 |
#lac ⇒ Object (readonly)
Returns the value of attribute lac.
3 4 5 |
# File 'lib/gsm_tools/cell_global_id.rb', line 3 def lac @lac end |
#mcc ⇒ Object (readonly)
Returns the value of attribute mcc.
3 4 5 |
# File 'lib/gsm_tools/cell_global_id.rb', line 3 def mcc @mcc end |
#mnc ⇒ Object (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_value ⇒ Object (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 |