memory_record 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 0a0d02478e038db4812bab5276b78fea07776ab4
4
- data.tar.gz: 98d8b5e8afc8d4953dc71e240112ea96deb13bcc
3
+ metadata.gz: 38453335376c705928d3272ad78e3803060f009c
4
+ data.tar.gz: 629b27607427d553237b8ad44b8d78ff55c21428
5
5
  SHA512:
6
- metadata.gz: 57018d07d34f7087d497ed1e31df045590b3ba664607a2990c65ac5aa1cf0e6f3af45c72790a0dc576da73dc1412b66f6ed9de2773e0c0de41485b3371f6a4a5
7
- data.tar.gz: 37dc4b8c4ff4a17d5a70e1681993b42d65186a7b3cfdd4b04b1de74dd3e8fd31a26013a275a4226422130ae3a857b22a3c9246cd57f55de6ea9b4ac1c22092d3
6
+ metadata.gz: 9e333eb93e434d2cb83dac1909366daebbefd8890fb8fde55dc2cf859f913b4cc83b13ea836755271d87b56c83d7b843399ce86d9b93aa489e7ecb5ddebfbb15
7
+ data.tar.gz: e0f422196c47fc513dcf4bee670c1aca3d41706f30ef76baf7f617b0a959f6cfa38aa60b213fc92d98643defd4c8700d32d492ae4d6faf7d676600641504999f
data/README.org CHANGED
@@ -1,30 +1,47 @@
1
- * A small number of records Easy handling library
1
+ * MemoryRecord
2
+
3
+ A small number of records Easy handling library
4
+
5
+ ** Installation
6
+
7
+ Install as a standalone gem
8
+
9
+ #+BEGIN_SRC shell
10
+ $ gem install memory_record
11
+ #+END_SRC
12
+
13
+ Or install within application using Gemfile
14
+
15
+ #+BEGIN_SRC shell
16
+ $ bundle add memory_record
17
+ $ bundle install
18
+ #+END_SRC
19
+
20
+ ** Examples
21
+
22
+ *** Basic usage
2
23
 
3
24
  #+BEGIN_SRC ruby
4
- class Direction
25
+ class Language
5
26
  include MemoryRecord
6
27
  memory_record [
7
- {key: :left, name: "", vector: [-1, 0]},
8
- {key: :right, name: "", vector: [ 1, 0]},
28
+ {key: :lisp, author: "John McCarthy" },
29
+ {key: :c, author: "Dennis Ritchie" },
30
+ {key: :ruby, author: "Yukihiro Matsumoto" },
9
31
  ], attr_reader_auto: true
10
32
 
11
- def long_name
12
- "#{key}:#{name}"
33
+ def mr_author
34
+ "Mr. #{author}"
13
35
  end
14
36
  end
15
37
 
16
- Direction.collect(&:name) # => ["←", "→"]
17
- Direction.keys # => [:left, :right]
18
-
19
- Direction[:right].key # => :right
20
- Direction[:right].code # => 1
21
- Direction[:right].vector # => [1, 0]
22
- Direction[:right].long_name # => "right:→"
23
-
24
- Direction[1].key # => :right
38
+ Language[:ruby].key # => :ruby
39
+ Language[:ruby].code # => 2
40
+ Language[:ruby].author # => "Yukihiro Matsumoto"
41
+ Language[:ruby].mr_author # => "Mr. Yukihiro Matsumoto"
25
42
 
26
- Direction[:up] # => nil
27
- Direction.fetch(:up) rescue $! # => #<KeyError: Direction.fetch(:up) does not match anything。
43
+ Language.keys # => [:lisp, :c, :ruby]
44
+ Language.collect(&:author) # => ["John McCarthy", "Dennis Ritchie", "Yukihiro Matsumoto"]
28
45
  #+END_SRC
29
46
 
30
47
  *** How to decide =code= yourself?
@@ -49,8 +66,8 @@ Foo.collect(&:code) # => [1, 2, 3]
49
66
  =Enumerable= extended, so that =each= method is available
50
67
 
51
68
  #+BEGIN_SRC ruby
52
- Foo.each {|v| ... }
53
- Foo.collect {|v| ... }
69
+ Foo.each { |e| ... }
70
+ Foo.collect { |e| ... }
54
71
  #+END_SRC
55
72
 
56
73
  *** How do I submit a form to select in Rails?
@@ -1,16 +1,23 @@
1
1
  $LOAD_PATH.unshift '../lib'
2
2
  require 'memory_record'
3
3
 
4
- class Foo
4
+ class Language
5
5
  include MemoryRecord
6
6
  memory_record [
7
- {key: :male, name: 'otoko'},
8
- {key: :female, name: 'onna'},
9
- ], attr_reader: :name
7
+ {key: :lisp, author: "John McCarthy" },
8
+ {key: :c, author: "Dennis Ritchie" },
9
+ {key: :ruby, author: "Yukihiro Matsumoto" },
10
+ ], attr_reader_auto: true
11
+
12
+ def mr_author
13
+ "Mr. #{author}"
14
+ end
10
15
  end
11
16
 
12
- Foo[:male] # => #<Foo:0x007ff459a494a8 @attributes={:key=>:male, :name=>"otoko", :code=>0}>
13
- Foo[:female] # => #<Foo:0x007ff459a49390 @attributes={:key=>:female, :name=>"onna", :code=>1}>
17
+ Language[:ruby].key # => :ruby
18
+ Language[:ruby].code # => 2
19
+ Language[:ruby].author # => "Yukihiro Matsumoto"
20
+ Language[:ruby].mr_author # => "Mr. Yukihiro Matsumoto"
14
21
 
15
- Foo[:male].name # => "otoko"
16
- Foo[:female].name # => "onna"
22
+ Language.keys # => [:lisp, :c, :ruby]
23
+ Language.collect(&:author) # => ["John McCarthy", "Dennis Ritchie", "Yukihiro Matsumoto"]
@@ -1,3 +1,3 @@
1
1
  module MemoryRecord
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memory_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - akicho8