crstruct 0.1.191207 → 0.1.210920

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 209a6ae14aeccf1e9a288b8cff5bc23d087db926e8b70bfb56a80584f91bd213
4
- data.tar.gz: d831dbb9f99e53fbc4108ed912f03f6c183504a9f6b4db55a774dbc5d3f88bf8
3
+ metadata.gz: dfe7c0590726e9eb559dc81a08b23c3867cfea18ef838ee5c28a5ae77cd4ee6b
4
+ data.tar.gz: b8b79defb6d76340f1f990903c8b48a72d25b02a9daa172bb22853a073f22752
5
5
  SHA512:
6
- metadata.gz: bb1664c894671291901cb2fde5045a617f8f36c279a688fc424cfbaff99210bdd53eb2cfb8654ed7494c65f8ab97ed7ffe367f1958e127388dee3d44fcded021
7
- data.tar.gz: 6382accd098940a5f62f18e8e00491941cc206abd6379532442edd24c3dca926ac83f6dd521f2227dab361291372d5777dc95c1d8924a75f959a65325acef3c3
6
+ metadata.gz: 0b3932c83bcb8dbbcfe8f407296719d3655e488cc1ab357586d4a941f7a7af478a58361201509071ccfc9b107bc78548bfa73384e93aadf23012eca22dfb7c33
7
+ data.tar.gz: 59ab70e0cc26137e1b70a04bad5049374031222deacefe348b2ca2cbb6872dcebdee8c70cd2638cb44e532dbbf3c46cb1da7cdbe2e1a6493ec4c2baddc46f5cf
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # crstruct
2
2
 
3
+ * [VERSION 0.1.210920](https://www.github.com/carlosjhr64/crstruct/releases)
3
4
  * [github](https://www.github.com/carlosjhr64/crstruct)
4
5
  * [rubygems](https://rubygems.org/gems/crstruct)
5
6
 
@@ -13,97 +14,74 @@ no "Update"...
13
14
  no "Delete".
14
15
 
15
16
  ## INSTALL:
16
-
17
- gem install crstruct
18
-
17
+ ```console
18
+ $ gem install crstruct
19
+ ```
19
20
  ## SYNOPSIS
20
21
 
21
22
  The following shows the intended use of CRStruct::Open:
22
-
23
- require 'crstruct'
24
-
25
- s = CRStruct::Open.new
26
- s.a = "A" #=> "A"
27
-
28
- begin
29
- # Not allowed to reset s.a...
30
- s.a = "B"
31
- # as there's no actual s.a=...
32
- rescue NoMethodError
33
- s.b = "B" #=> "B"
34
- end
35
-
36
- if s.b == "B" #=> true
37
- begin
38
- # There is no s.c...
39
- puts "s.c is #{s.c}"
40
- rescue NoMethodError
41
- s.c = "C" #=> "C"
42
- # Output:
43
- # s.a is A
44
- # s.b is B
45
- # s.c is C
46
- puts "s.a is #{s.a}"
47
- puts "s.b is #{s.b}"
48
- puts "s.c is #{s.c}"
49
- end
50
- end
51
-
23
+ ```ruby
24
+ require 'crstruct'
25
+
26
+ s = CRStruct::Open.new
27
+ s.a = "A"
28
+ s.a #=> "A"
29
+
30
+ begin
31
+ # Not allowed to reset s.a...
32
+ s.a = "B" # raises error
33
+ # as there's no actual s.a=...
34
+ rescue NoMethodError
35
+ s.b = "B"
36
+ end
37
+ s.a #=> "A"
38
+ s.b #=> "B"
39
+
40
+ if s.b == "B"
41
+ begin
42
+ s.c # There is no s.c so raises
43
+ rescue NoMethodError
44
+ s.c = "C"
45
+ end
46
+ end
47
+ s.a #=> "A"
48
+ s.b #=> "B"
49
+ s.c #=> "C"
50
+ ```
52
51
  There's also a subclass CRStruct::Registered:
53
-
54
- require 'crstruct'
55
-
56
- s = CRStruct::Registered.new :a, :b, :c
57
- s.a = "A" #=> "A"
58
- s.b = "B" #=> "B"
59
- s.c = "C" #=> "C"
60
- begin
61
- s.d = "D"
62
- rescue NoMethodError
63
- # Can't set :d as it was not registered with s.
64
- end
65
- # Output:
66
- # #<CRStruct::Registered:0x0000561d37006b08
67
- # @h={:a=>"A", :b=>"B", :c=>"C"},
68
- # @r=[:a, :b, :c]>
69
- pp s
70
-
71
-
52
+ ```ruby
53
+ s = CRStruct::Registered.new :a, :b, :c
54
+ s.a = "A"
55
+ s.b = "B"
56
+ s.c = "C"
57
+ begin
58
+ s.d = "D"
59
+ rescue NoMethodError
60
+ # Can't set :d as it was not registered with s.
61
+ end
62
+ s
63
+ #~> ^#<CRStruct::Registered:0x\h+ @r=\[:a, :b, :c\], @h=\{:a=>"A", :b=>"B", :c=>"C"\}>$
64
+ ```
72
65
  ## MORE
73
66
 
74
67
  The following can be done, but
75
68
  you'd be circumventing the intended use:
76
-
77
- require 'crstruct'
78
-
79
- s = CRStruct::Open.new a: "A", b: "B"
80
- s.set!(:c, "C") #=> "C"
81
-
82
- # s' internal hash does not have :d
83
- if s.get?(:d).nil?
84
- # Output:
85
- # s.a is A
86
- # s.b is B
87
- # s.c is C
88
- # s.d is nil
89
- puts "s.a is #{s.get?(:a)}"
90
- puts "s.b is #{s.get?(:b)}"
91
- puts "s.c is #{s.get?(:c)}"
92
- puts "s.d is #{s.get?(:d)}"
93
- # Output:
94
- # {:a=>"A", :b=>"B", :c=>"C"}
95
- pp s.to_h
96
- end
97
-
98
- # The :free? method determines if a Symbol is avaible for setting.
99
- s.free?(:to_s) #=> false
100
- s.free?(:d) #=> true
101
-
69
+ ```ruby
70
+ s = CRStruct::Open.new a: "A", b: "B"
71
+ s.get?(:c) #=> nil
72
+ s.set!(:c, "C")
73
+ s.get?(:c) #=> "C"
74
+ s.c #=> "C"
75
+
76
+ # The :free? method determines if a Symbol is available for setting.
77
+ s.free?(:to_s) #=> false
78
+ s.free?(:d) #=> true
79
+ ```
102
80
  ## LICENSE:
103
81
 
104
82
  (The MIT License)
105
83
 
106
- Copyright (c) 2019 CarlosJHR64
84
+ Copyright (c) 2021 CarlosJHR64
107
85
 
108
86
  Permission is hereby granted, free of charge, to any person obtaining
109
87
  a copy of this software and associated documentation files (the
data/lib/crstruct/open.rb CHANGED
@@ -16,7 +16,7 @@ module CRStruct
16
16
 
17
17
  #########################################
18
18
  ### free?, set!, and get? ###
19
- # make purposefull access to @h possible,
19
+ # make purposeful access to @h possible,
20
20
  # and easier to subclass CRStruct.
21
21
  #########################################
22
22
 
@@ -46,4 +46,3 @@ module CRStruct
46
46
  end
47
47
  end
48
48
  end
49
-
@@ -20,4 +20,3 @@ module CRStruct
20
20
  end
21
21
  end
22
22
  end
23
-
data/lib/crstruct.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module CRStruct
2
- VERSION = '0.1.191207'
3
- require 'crstruct/open'
2
+ VERSION = '0.1.210920'
3
+ require_relative 'crstruct/open'
4
4
  autoload :Registered, 'crstruct/registered'
5
5
  end
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crstruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.191207
4
+ version: 0.1.210920
5
5
  platform: ruby
6
6
  authors:
7
- - carlosjhr64
8
- autorequire:
7
+ - CarlosJHR64
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-07 00:00:00.000000000 Z
11
+ date: 2021-09-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  Ruby gem for an extremely lite OpenStruct like class with
@@ -30,7 +30,7 @@ homepage: https://github.com/carlosjhr64/crstruct
30
30
  licenses:
31
31
  - MIT
32
32
  metadata: {}
33
- post_install_message:
33
+ post_install_message:
34
34
  rdoc_options: []
35
35
  require_paths:
36
36
  - lib
@@ -45,9 +45,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  requirements:
48
- - 'ruby: ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]'
49
- rubygems_version: 3.0.3
50
- signing_key:
48
+ - 'ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]'
49
+ rubygems_version: 3.2.22
50
+ signing_key:
51
51
  specification_version: 4
52
52
  summary: Ruby gem for an extremely lite OpenStruct like class with attributes that
53
53
  can only be set once, and then read thereafter.