import_remotecontrol 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/get_code_list.rb +92 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODYzZTU0ODYxN2ZkYTYxYTEzODAxNmU3MTRlYWIyNzdlODRjOGNiMw==
4
+ NjRkZjY0NTNiYWNmYjdhNzdjNmFiNWUzNjkwYzA2NmQ3NDhiMzcwNQ==
5
5
  data.tar.gz: !binary |-
6
- ZmY0YTQ5MjMxNWFlOWM2ZjhjNzZmMTllOGYzMjNhOWU2OTc5NTUxNA==
6
+ OGEzOTM4NDkyNjA3MGVkYTJmNTRhMjU3YzM4N2I3ZDUwZmQwMWEzZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NzI1N2E5NzJkOTYwYTk3OTRiZjE4ZDgwNmMxYjY4YmRkN2EwNGQwNjdmOWIx
10
- ZGE0YmEwZWE5NDI0YTJmOGM4NmZhYjFjMjM3OTMyZmM5MDZhM2NkZjdkM2My
11
- YTY2NTk5MmI3YTc3OWJiZjMwZjU3MDQ3OGM4MjVjOGI2YmNkZTM=
9
+ OWJhMDZlMmQ0ZTcxM2NlNWNjMWVjNWUzNjNkNWIxNTE5ZmIwNTI5NjgzNTkw
10
+ ODJiYmMxZTIwMmEyOTEwY2I4MmM2MGVmYTk4ZWFhZTMwZTczYWMyZjM1NDc0
11
+ MWM5MmI2ZGI4MWJkNzc0ODNhOGM4MjY0NmVkNDBiMThlMzg1OWY=
12
12
  data.tar.gz: !binary |-
13
- YTZjMDE3ODQ1Zjc4ODdlNDYzZjI0ZTU4NzlkMTk5YmZlNDRmODRiYTdjMWNk
14
- Y2RkZWJkNzJkNDA5YWNkOTQ3OGRkNjU5MDAyNGRiMGNkZTI5ODc2N2E1YTQz
15
- ZWIxYmI3ZmVlZmYxOTM3YWQzM2NjMGEwMzM0NTI3N2M3MTE1ZDQ=
13
+ MWI2YmM5YTYwY2MyMmEwZDViZWFkMjkxMDBjZjI0ZTYxZTU3MWYxYzMxNGIy
14
+ ZGU1YmYwZDVlMDk4YmM0NmQ0YzkwMzg4ZDMzMzM2NThhZGVjMTEzMTJhN2Q0
15
+ NWQ5ZjY2Nzc5NWIzNjBjYWFiYzZkMzIwMjc5ZGQ0M2Q3MWIyNGE=
@@ -0,0 +1,92 @@
1
+ module GetCodeList
2
+ # To change this template use File | Settings | File Templates.
3
+
4
+ BRAND = "brand"
5
+ PROTOCOLNAME="protocol_name"
6
+ CODE = "code"
7
+ METHOD_NAME = "method_name"
8
+
9
+ #获取错误信息用于抛出错误
10
+ def self.get_error_msg(error,options={})
11
+ ret = ""
12
+ ret = ret + "ClassName: import_remotecontrol gem "
13
+ if options["method_name"]
14
+ ret = ret + "MethodName: #{options["method_name"]} "
15
+ end
16
+ if error
17
+ ret = ret + "Error Msg: #{error.to_s}"
18
+ end
19
+ ret
20
+ end
21
+
22
+
23
+
24
+
25
+
26
+ def self.getlist(data)
27
+ codes = data["codes"]
28
+ _codes = {}
29
+ case data[BRAND]
30
+ when "长虹"
31
+ codes.each do |key,value|
32
+ _codes.merge!({key=>changHong(value)})
33
+ end
34
+ when "创维"
35
+ codes.each do |key,value|
36
+ _codes.merge!({key=>chuangWei(value)})
37
+ end
38
+ end
39
+ data["codes"] = _codes
40
+ data
41
+ end
42
+
43
+
44
+ def self.changHong(code)
45
+ ret = ""
46
+ case code[PROTOCOLNAME]
47
+ when "EXT_NEC"
48
+ ret = changHongExtNec(code[CODE])
49
+ end
50
+ ret
51
+ end
52
+
53
+ def self.chuangWei(code)
54
+ ret = ""
55
+ case code[PROTOCOLNAME]
56
+ when "CUT_NEC"
57
+ ret = changHongExtNec(code[CODE])
58
+ end
59
+ ret
60
+ end
61
+
62
+
63
+
64
+ #对长虹的扩展NEC编码类型的编码数组进行处理
65
+ def self.changHongExtNec(code)
66
+ begin
67
+ codes = code.split(":")
68
+ ret = "#{codes[0]}:#{codes[1]}:#{codes[2]}:"
69
+ __code = Integer("0x#{codes[2].to_s}")
70
+ __code = (~__code)&Integer(0b1111)
71
+ ret = ret + __code.to_s(16)
72
+ rescue => err
73
+ raise RuntimeError, get_error_msg("Protocol Error, Error msg : #{err.to_s}",{METHOD_NAME => "changHongExtNec"})
74
+ end
75
+ end
76
+
77
+ #对创维的精简NEC编码类型的编码数组进行处理
78
+ def self.chuangWeiCutNec(code)
79
+ begin
80
+ codes = code.split(":")
81
+ ret = "#{codes[0]}:#{codes[0]}:#{codes[1]}:"
82
+ __code = Integer("0x#{codes[1].to_s}")
83
+ __code = (~__code)&Integer(0b1111)
84
+ ret = ret + __code.to_s(16)
85
+ rescue => err
86
+ raise RuntimeError, get_error_msg("Protocol Error, Error msg : #{err.to_s}",{METHOD_NAME => "chuangWeiCutNec"})
87
+ end
88
+ end
89
+
90
+ end
91
+
92
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: import_remotecontrol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - zql
@@ -18,6 +18,7 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - lib/import_remotecontrol.rb
20
20
  - lib/import_code.rb
21
+ - lib/get_code_list.rb
21
22
  homepage: http://rubygems.org/gems/import_remotecontrol
22
23
  licenses: []
23
24
  metadata: {}