automotive-ecu 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad8f4f30b32824a37a57939951230876c96e1e6de5d89939fe831eb68b6fd92f
4
- data.tar.gz: 397829925fb22b56f76ddd60820c52b8a89739b2e0dccbfc94ad8fb174acec94
3
+ metadata.gz: a191c6cadff7a9e20bf0a1065f3b041b3f2374e8a0a93babcbadf5cd44f96bc3
4
+ data.tar.gz: 2b87b8a19a794165daf7fa7d4c682e004ac0fd8cc2cc0f2d349ea8fc13b0dd33
5
5
  SHA512:
6
- metadata.gz: d51985201cc46cfe5f4cdab85903f71b3018983fd2053752487cc0295587f9788760e97249da7f0fca07c277fd2fd0982c7d7825d414d21c19654c0afe6da4b6
7
- data.tar.gz: 611e2e6b00449f3303f4edf383af46151cce36d340bf6ca67cd932a95739e86865a146f76b5e1b436088c175620db376bef8995fe74c8d61d63d3e6b4dce8623
6
+ metadata.gz: d030f9137511a93fa52dd8266f819721e84603b6a9a317976082d29e0be7c7300b14e3c7abac5a9a77bf6dfb0b47f0c504b064c96ae714f8914176d22777ad57
7
+ data.tar.gz: 83df1db99999d6d8e77c5591c6fd01be988774cc40f149ed6c954867db6204f8e7c238e1ad7b43592b8ebacd2745cf355f3c6970664278f394fb9b0a72429a34
@@ -5,7 +5,7 @@ class Ecu
5
5
  end
6
6
 
7
7
  def to_dcm(indented=false)
8
- fmtstr = indented ? "%-26s%s\n" : "%s %s\n"
8
+ fmtstr = indented ? "%-25s%s\n" : "%s %s\n"
9
9
 
10
10
  sprintf(fmtstr, type.upcase, name).tap do |str|
11
11
  str << " LANGNAME #{description.enquote}\n" if description
@@ -7,7 +7,7 @@ class Ecu
7
7
  end
8
8
 
9
9
  def to_dcm(indented=false)
10
- fmtstr = indented ? "%-26s%s %s" : "%s %s %d"
10
+ fmtstr = indented ? "%-25s%s %s" : "%s %s %d"
11
11
 
12
12
  sprintf(fmtstr, type.upcase, name, xdim).tap do |str|
13
13
  str << " @ #{ydim}" if ydim != 1
@@ -17,8 +17,8 @@ class Ecu
17
17
  str << " EINHEIT_W #{unit.enquote}\n" if unit
18
18
  value.each do |row|
19
19
  str << case row.first
20
- when Numeric then " WERT #{row.join(" ")}\n"
21
- when String then " TEXT #{row.map(&:enquote).join(" ")}\n"
20
+ when Numeric then " WERT #{row.join(" ")}\n"
21
+ when String then " TEXT #{row.map(&:enquote).join(" ")}\n"
22
22
  end
23
23
  end
24
24
  str << "END\n"
@@ -5,7 +5,7 @@ class Ecu
5
5
  end
6
6
 
7
7
  def to_dcm(indented=false)
8
- fmtstr = indented ? "%-26s%s %s %s\n" : "%s %s %d %d\n"
8
+ fmtstr = indented ? "%-25s%s %s %s\n" : "%s %s %d %d\n"
9
9
 
10
10
  sprintf(fmtstr, type.upcase, name, xdim, ydim).tap do |str|
11
11
  str << " LANGNAME #{description.enquote}\n" if description
@@ -14,8 +14,8 @@ class Ecu
14
14
  str << " EINHEIT_Y #{yunit.enquote}\n" if yunit
15
15
  str << " EINHEIT_W #{unit.enquote}\n" if unit
16
16
  str << case xvalue.first
17
- when Numeric then " ST/X #{xvalue.join(" ")}\n"
18
- when String then " ST_TX/X #{xvalue.map(&:enquote).join(" ")}\n"
17
+ when Numeric then " ST/X #{xvalue.join(" ")}\n"
18
+ when String then " ST_TX/X #{xvalue.map(&:enquote).join(" ")}\n"
19
19
  end
20
20
  yvalue.each_with_index do |entry, idx|
21
21
  str << case entry
@@ -23,8 +23,8 @@ class Ecu
23
23
  when String then " ST_TX/Y #{entry.enquote}\n"
24
24
  end
25
25
  str << case value[idx].first
26
- when Numeric then " WERT #{value[idx].join(" ")}\n"
27
- when String then " TEXT #{value[idx].map(&:enquote).join(" ")}\n"
26
+ when Numeric then " WERT #{value[idx].join(" ")}\n"
27
+ when String then " TEXT #{value[idx].map(&:enquote).join(" ")}\n"
28
28
  end
29
29
  end
30
30
  str << "END\n"
@@ -5,7 +5,7 @@ class Ecu
5
5
  end
6
6
 
7
7
  def to_dcm(indented=false)
8
- fmtstr = indented ? "%-26s%s %s\n" : "%s %s %d\n"
8
+ fmtstr = indented ? "%-25s%s %s\n" : "%s %s %d\n"
9
9
 
10
10
  sprintf(fmtstr, type.upcase, name, xdim).tap do |str|
11
11
  str << " LANGNAME #{description.enquote}\n" if description
@@ -13,12 +13,12 @@ class Ecu
13
13
  str << " EINHEIT_X #{xunit.enquote}\n" if xunit
14
14
  str << " EINHEIT_W #{unit.enquote}\n" if unit
15
15
  str << case xvalue.first
16
- when Numeric then " ST/X #{xvalue.join(" ")}\n"
17
- when String then " ST_TX/X #{xvalue.map(&:enquote).join(" ")}\n"
16
+ when Numeric then " ST/X #{xvalue.join(" ")}\n"
17
+ when String then " ST_TX/X #{xvalue.map(&:enquote).join(" ")}\n"
18
18
  end
19
19
  str << case value.first
20
- when Numeric then " WERT #{value.join(" ")}\n"
21
- when String then " TEXT #{value.map(&:enquote).join(" ")}\n"
20
+ when Numeric then " WERT #{value.join(" ")}\n"
21
+ when String then " TEXT #{value.map(&:enquote).join(" ")}\n"
22
22
  end
23
23
  str << "END\n"
24
24
  end
@@ -39,9 +39,11 @@ class Ecu
39
39
  end
40
40
 
41
41
  def self.numeric_value(str)
42
- return str.to_f if str.match?(/^\d+\.$/)
43
-
44
- Float(str)
42
+ case str
43
+ in /^\d+$/ then str.to_i
44
+ in /^\d+\.$/ then str.to_f
45
+ else Float(str)
46
+ end
45
47
  end
46
48
 
47
49
  end
@@ -5,15 +5,15 @@ class Ecu
5
5
  end
6
6
 
7
7
  def to_dcm(indented=false)
8
- fmtstr = indented ? "%-26s%s %s\n" : "%s %s %d\n"
8
+ fmtstr = indented ? "%-25s%s %s\n" : "%s %s %d\n"
9
9
 
10
10
  sprintf(fmtstr, type.upcase, name, xdim).tap do |str|
11
11
  str << " LANGNAME #{description.enquote}\n" if description
12
12
  str << " FUNKTION #{function}\n" if function
13
13
  str << " EINHEIT_X #{xunit.enquote}\n" if xunit
14
14
  str << case xvalue.first
15
- when Numeric then " ST/X #{xvalue.join(" ")}\n"
16
- when String then " ST_TX/X #{xvalue.map(&:enquote).join(" ")}\n"
15
+ when Numeric then " ST/X #{xvalue.join(" ")}\n"
16
+ when String then " ST_TX/X #{xvalue.map(&:enquote).join(" ")}\n"
17
17
  end
18
18
  str << "END\n"
19
19
  end
data/lib/ecu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Ecu
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: automotive-ecu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Mueller