sgao-ruby-demo 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2b7fa0caf073bf4fe3e5a0e99ec78271ec1e544b39ee356753349ab04384c787
4
+ data.tar.gz: e9868cea1a7fc5b2352706e7c5ae2451aee2a11b38667cbecdceb41e3c82d6a3
5
+ SHA512:
6
+ metadata.gz: d8e4c1857306db0f6e3dc1e98e67ee9ea99430af0895744e1434c09300c754593a099de47d463d4c2e437fcbe3a9fe3e0c0110c4ea70a6cdf261e4a0d853a7dd
7
+ data.tar.gz: c6d9a76403a501e2194ab385b74c194043cd3a96ab245262dc9ddb5760482802f183fdaf7a2ba37758a7a5dbf599ac72878092a7a2a7d8f1884cd5da91ca0a58
@@ -0,0 +1,24 @@
1
+ require './foo'
2
+ require File.dirname(__FILE__) + '/mods'
3
+
4
+ class Application
5
+ include Mods::LevelOne
6
+
7
+ def self.main(args=[])
8
+ f = Mods::LevelOne::FooClass.new
9
+ f.foo
10
+ fo = Foo.new
11
+ fo.foo
12
+
13
+ Mods::LevelOne::tue
14
+
15
+ watc = Mods::LevelOne::WatClass.new
16
+ watc.wat
17
+ end
18
+
19
+ def my_bar
20
+ bar
21
+ end
22
+ end
23
+
24
+ Application.main
data/lib/foo.rb ADDED
@@ -0,0 +1,7 @@
1
+ class Foo
2
+
3
+ def foo
4
+ p "foo in Foo"
5
+ end
6
+
7
+ end
data/lib/mods.rb ADDED
@@ -0,0 +1,42 @@
1
+ module Mods
2
+ PI = 3.14
3
+ module LevelOne
4
+ PI = 9.99
5
+ class FooClass
6
+ PI = 3.15
7
+ def foo
8
+ puts PI
9
+ puts "Mods::LevelOne::FooClass foo method called"
10
+ end
11
+ end
12
+
13
+ class PiClass
14
+ PI = 3.16
15
+ end
16
+
17
+ class WatClass < PiClass
18
+ #PI = 3.33
19
+ def wat
20
+ puts PI
21
+ puts "Mods::LevelOne::WatClass wat method called"
22
+ end
23
+ def self.inspect_nesting
24
+
25
+ puts Module.nesting.inspect
26
+ puts PI
27
+ end
28
+ end
29
+
30
+ def bar
31
+ puts "Mods::LevelOne instance bar method called"
32
+ end
33
+
34
+ def self.tue
35
+ puts "Mods::LevelOne tue method called"
36
+ end
37
+ end
38
+
39
+ def bar
40
+ puts "Mods instance bar method called"
41
+ end
42
+ end
data/lib/point.rb ADDED
@@ -0,0 +1,87 @@
1
+ module Foo
2
+ def foo
3
+ p 'foo from module Foo'
4
+ end
5
+
6
+ def show(something='world')
7
+ p "We are showing #{something} from module Foo"
8
+ end
9
+ end
10
+
11
+ module Show
12
+ def show(something='world')
13
+ p "We are showing #{something} from module Show"
14
+ end
15
+
16
+ def time
17
+ p Time.now
18
+ end
19
+
20
+ def self.add(p1, p2)
21
+ p1 + p2
22
+ end
23
+ end
24
+
25
+ class BasePoint
26
+ @@base_id = 100
27
+
28
+ def base_group
29
+ p 'my base group'
30
+ end
31
+
32
+ def self.minusone
33
+ @@base_id -= 1
34
+ end
35
+ end
36
+
37
+ class AbstractPoint < BasePoint
38
+ $x = 10
39
+ @@id=1
40
+
41
+ ENV = "local"
42
+
43
+ def group(x, y)
44
+ p "group point [#{@x},#{@y}], ID = #{@@id}"
45
+ end
46
+
47
+ def self.addone
48
+ @@id += 1
49
+ end
50
+ end
51
+
52
+ class Point < AbstractPoint
53
+ include Foo
54
+ include Show
55
+
56
+
57
+ def initialize(x=0, y=0)
58
+ @x, @y = x, y
59
+ end
60
+
61
+ class << self
62
+ def hello(name='world')
63
+ p "hello #{name}"
64
+ end
65
+ end
66
+
67
+ def to_s
68
+ "[#{@x},#{@y}] - #{@@id} - #{@@base_id}"
69
+ end
70
+
71
+ end
72
+
73
+ class << Point
74
+ def hackx
75
+ p 'hack x'
76
+ end
77
+ end
78
+
79
+ def Point.hack
80
+ p 'hack from the outside of class Point'
81
+ end
82
+
83
+ class Apple
84
+ def show
85
+ $x += 2
86
+ end
87
+ end
@@ -0,0 +1,36 @@
1
+ class TokenRequest
2
+
3
+ attr_reader :token
4
+
5
+ def +(b)
6
+ puts b
7
+ end
8
+
9
+ alias plus +
10
+
11
+ def remember(t)
12
+ self.token = t
13
+ puts token
14
+ end
15
+
16
+ def set(t)
17
+ @token = t
18
+ end
19
+
20
+ def foo(num, b1, b2)
21
+ p num
22
+ b1.call(num)
23
+ b2.call(num)
24
+ num
25
+ end
26
+
27
+ def bar(&b)
28
+ a = [1 , 2, 3, 4, 5, 6]
29
+ b.call a
30
+ yield a
31
+ yield a
32
+ a
33
+ end
34
+ end
35
+
36
+
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sgao-ruby-demo
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - sgao
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-04-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This is my first gem!
14
+ email: sgao@beckman.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/application.rb
20
+ - lib/foo.rb
21
+ - lib/mods.rb
22
+ - lib/point.rb
23
+ - lib/token_request.rb
24
+ homepage: https://github.com/sgao-becls/ruby-demo
25
+ licenses: []
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubygems_version: 3.0.9
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: A ruby demo
46
+ test_files: []