gemstones 1.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a02805b564e2ed6701222273a25d40fb0b67ceb211f389aa880e4a63b6fe0465
4
+ data.tar.gz: 16753e8dd889a54128c37ff35570ee658388f1d02abbf6b60e63307ee49dd62e
5
+ SHA512:
6
+ metadata.gz: e2d2554a880712a98d10406d96ecfcfb04845ce79fb70eac0515bac45f72c6fe01496b8bcec43f27388ad7d7514b433dd9d2cd7c5c9c92fc14c77826c225871e
7
+ data.tar.gz: e878b342aca9f501ef7c0c5d89a941d3e6f315bfb0f02f8c72474f5dd8640032075eba529f21c5572c501cc52102d05a0429845ab7851bc43d4d5f80fffe36f0
@@ -0,0 +1,25 @@
1
+ =begin
2
+
3
+ cities =['Djelfa', 'Algiers', 'Oran', 'Constantine'];
4
+
5
+ puts cities.first # Djelfa
6
+ puts cities.last # Constantine
7
+ puts cities[2] # Oran
8
+ cities.push('Annaba') # adds Annaba to the array
9
+ cities << 'Setif' # adds Setif to the array
10
+ puts cities
11
+ cities.pop # removes Setif from the array and prints it to the console
12
+ puts "========="
13
+ puts cities
14
+
15
+ upcities = cities.map { |city| city.upcase }
16
+ puts upcities
17
+
18
+ =end
19
+
20
+ # select only numbers less than 5
21
+
22
+ numbers = [0,1,2,3,4,5,6,7,8,9]
23
+
24
+ puts numbers.select { |number| number < 5 }
25
+
@@ -0,0 +1,12 @@
1
+ class Customer
2
+ def initialize(name)
3
+ @name = name
4
+ end
5
+ def getName
6
+ puts @name
7
+ end
8
+ end
9
+
10
+
11
+ ilyes = Customer.new("ilyes")
12
+ ilyes.getName
@@ -0,0 +1,14 @@
1
+ =begin
2
+ this is a multiline comment.
3
+ we use this sort of comments to... well..., write comments
4
+ in multiple lines...
5
+ -----------
6
+ $x = 4
7
+ print "#{$x} is greater than three" unless $x <= 3
8
+ -----------
9
+ x = true
10
+ puts "Hello world" if x
11
+ -----------
12
+ x = 5
13
+ puts x == 4 ? 'yay' : 'nay'
14
+ =end
@@ -0,0 +1,25 @@
1
+ =begin
2
+
3
+ Note: Hashes can be written in the way as below or in the same way
4
+ of writing JavaScript objects (starting from Ruby 1.9)
5
+
6
+ person = {:name => 'Ilyes', :age => 25, :job => 'programmer'}
7
+
8
+ puts person
9
+
10
+ person[:hobby] = 'coding'
11
+
12
+ puts "============"
13
+ person.each do |key, value|
14
+ puts "#{key}: #{value}"
15
+ end
16
+ puts "============"
17
+
18
+ =end
19
+
20
+ person = {:name => 'Ilyes', :age => 25, :job => 'programmer'}
21
+
22
+
23
+
24
+ puts person.has_key?(:name) # true
25
+ puts person.has_key?(:hobby) # false
@@ -0,0 +1,7 @@
1
+ city = {
2
+ :name => "Djelfa",
3
+ :population => 480000,
4
+ :code => 17
5
+ }
6
+
7
+ puts city.inspect
@@ -0,0 +1,39 @@
1
+ =begin
2
+ print "Gimme a number: "
3
+ x = gets.chomp.to_i
4
+ until x < 1
5
+ puts x
6
+ x -= 1
7
+ end
8
+ puts "Done!"
9
+ ---------------
10
+ a = ['y', 'Y']
11
+ begin
12
+ puts "Hello, there!"
13
+ answer = gets.chomp
14
+ end while a.include? answer
15
+ ---------------
16
+ for i in 1..15 do
17
+ puts i
18
+ end
19
+ ---------------
20
+ x = [1,2,3,4,5,6,7,8,9]
21
+
22
+ for i in x do
23
+ puts x
24
+ end
25
+ ---------------
26
+ cities = ['Djelfa', 'Algiers', 'Oran', 'Setif', 'Annaba', 'Constantine']
27
+ cities.each { |city| puts city}
28
+ ---------------
29
+ x = (0..5).to_a
30
+ puts x
31
+ ---------------
32
+ cities = ['Djelfa', 'Algiers', 'Oran', 'Setif', 'Annaba', 'Constantine']
33
+ cities.each do |city|
34
+ puts city
35
+ end
36
+ ---------------
37
+ =end
38
+
39
+
@@ -0,0 +1,5 @@
1
+ def greeting(name, options = {})
2
+ if options.empty?
3
+ return "Hello, everybody. My name is #{name}."
4
+ else
5
+ return "Hello, everybody. My name is #{name}. I am #{options[:age]} years old. I work as a #{options[:job]."
@@ -0,0 +1,3 @@
1
+ phone = "0666778899"
2
+
3
+ puts /^(06)\w+{8}$/.match(phone) # matches a phone number (Mobilis - DZA)
@@ -0,0 +1,7 @@
1
+ # puts 'Hello, everybody!'
2
+
3
+ require "tk"
4
+
5
+ TkRoot.new{ title 'Hello, everybody!' }
6
+
7
+ Tk.mainloop
@@ -0,0 +1,7 @@
1
+ $name = "ilyes" # global variable
2
+ puts $name
3
+
4
+ # local: normal naming like python
5
+
6
+ # class variable: @@
7
+ # instance variable: @
@@ -0,0 +1,8 @@
1
+ class Car
2
+ def on
3
+ "Car turned on"
4
+ end
5
+ end
6
+
7
+ car = Car.new
8
+ puts car.on
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gemstones
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ilyes Chouia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-01-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A collection of Ruby code examples
14
+ email: celyes02@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/basics/arrays.rb
20
+ - lib/basics/class.rb
21
+ - lib/basics/conditionals.rb
22
+ - lib/basics/hashes.rb
23
+ - lib/basics/inspect.rb
24
+ - lib/basics/loops.rb
25
+ - lib/basics/methods.rb
26
+ - lib/basics/regex.rb
27
+ - lib/basics/tk.rb
28
+ - lib/basics/variables.rb
29
+ - lib/oop/Car.rb
30
+ homepage: https://rubygems.org/gems/gemstones
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.1.4
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Gemstones
53
+ test_files: []