Class: Sample

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_gem.rb

Constant Summary collapse

MY_CONST =
123

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(i) ⇒ Sample

Returns a new instance of Sample.



27
28
29
# File 'lib/ruby_gem.rb', line 27

def initialize(i)
  @i = i
end

Class Method Details

.my_arrayObject

doc for Sample.my_array



23
24
25
# File 'lib/ruby_gem.rb', line 23

def self.my_array
  [1, 2, 'three']
end

.my_boolObject

doc for Sample.my_bool



13
14
15
# File 'lib/ruby_gem.rb', line 13

def self.my_bool
  true
end

.my_hashObject

doc for Sample.my_hash



18
19
20
# File 'lib/ruby_gem.rb', line 18

def self.my_hash
  {:a => 1, 'b' => 'two'}
end

.my_intObject

doc for Sample.my_int



8
9
10
# File 'lib/ruby_gem.rb', line 8

def self.my_int
  123
end

.my_stringObject

doc for Sample.my_string



3
4
5
# File 'lib/ruby_gem.rb', line 3

def self.my_string
  "some string"
end

Instance Method Details

#my_method(a, b) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/ruby_gem.rb', line 31

def my_method(a, b)
  c = 3
  b = 'four'
  l = b.length
  puts "#{@i}: #{b} has length #{l} (a=#{a}, b=#{b})"
  @i += 1
end