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 +4 -4
- data/README.org +36 -19
- data/examples/0110_basic.rb +15 -8
- data/lib/memory_record/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38453335376c705928d3272ad78e3803060f009c
|
4
|
+
data.tar.gz: 629b27607427d553237b8ad44b8d78ff55c21428
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e333eb93e434d2cb83dac1909366daebbefd8890fb8fde55dc2cf859f913b4cc83b13ea836755271d87b56c83d7b843399ce86d9b93aa489e7ecb5ddebfbb15
|
7
|
+
data.tar.gz: e0f422196c47fc513dcf4bee670c1aca3d41706f30ef76baf7f617b0a959f6cfa38aa60b213fc92d98643defd4c8700d32d492ae4d6faf7d676600641504999f
|
data/README.org
CHANGED
@@ -1,30 +1,47 @@
|
|
1
|
-
*
|
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
|
25
|
+
class Language
|
5
26
|
include MemoryRecord
|
6
27
|
memory_record [
|
7
|
-
{key: :
|
8
|
-
{key: :
|
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
|
12
|
-
"#{
|
33
|
+
def mr_author
|
34
|
+
"Mr. #{author}"
|
13
35
|
end
|
14
36
|
end
|
15
37
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
27
|
-
|
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 {|
|
53
|
-
Foo.collect {|
|
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?
|
data/examples/0110_basic.rb
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
$LOAD_PATH.unshift '../lib'
|
2
2
|
require 'memory_record'
|
3
3
|
|
4
|
-
class
|
4
|
+
class Language
|
5
5
|
include MemoryRecord
|
6
6
|
memory_record [
|
7
|
-
{key: :
|
8
|
-
{key: :
|
9
|
-
|
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
|
-
|
13
|
-
|
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
|
-
|
16
|
-
|
22
|
+
Language.keys # => [:lisp, :c, :ruby]
|
23
|
+
Language.collect(&:author) # => ["John McCarthy", "Dennis Ritchie", "Yukihiro Matsumoto"]
|