bytes_converter 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,7 +18,50 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ first:
22
+
23
+ ```ruby
24
+ require "bytes_converter"
25
+ ```
26
+
27
+ Converting strings to bytes:
28
+
29
+ ```ruby
30
+ BytesConverter::convert "some string" # --> Float
31
+ ```
32
+
33
+ where "some string" can be anything like in these examples:
34
+
35
+ ```ruby
36
+ BytesConverter::convert "12.3M" # --> 12897484.8
37
+ BytesConverter::convert "12.3" # --> 12.3 (no unit means bytes)
38
+ BytesConverter::convert "12.3 kilo bytes" # --> 12595.2
39
+ BytesConverter::convert "12.3 Megabytes" # --> 12897484.8
40
+ BytesConverter::convert "12.3 m" # --> 12897484.8
41
+ BytesConverter::convert "12.3 k" # --> 12595.2
42
+ BytesConverter::convert "12.3 bk" # --> 0.0 (b is not recognized)
43
+ BytesConverter::convert "12,3m" # --> 12897484.8
44
+ BytesConverter::convert "123" # --> 123
45
+ ```
46
+
47
+ You can add new unit as a hash. Let's say you want OrangeBytes unit:
48
+
49
+ ```ruby
50
+ orange = {"o" => 2}
51
+ BytesConverter::add_unit orange
52
+ ```
53
+
54
+ ... and remove it with:
55
+
56
+ ```ruby
57
+ BytesConverter::remove_unit "o"
58
+ ```
59
+
60
+ To get all available units:
61
+
62
+ ```ruby
63
+ BytesConverter::get_units # --> Hash
64
+ ```
22
65
 
23
66
  ## Contributing
24
67
 
@@ -45,10 +45,7 @@ module BytesConverter
45
45
 
46
46
  # getter for sizes
47
47
  def self.get_units
48
- @sizes.each do | key, value |
49
- puts "unit: #{key} = #{value}"
50
- end
51
- "end of list"
48
+ @sizes
52
49
  end
53
50
 
54
51
  # method removing size
@@ -1,3 +1,3 @@
1
1
  module BytesConverter
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bytes_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: