Sha256: 5cb02cfebec162a97f52ad8bca6b604f1043ad7a7c98a0a173c3ae6ceee23a42

Contents?: true

Size: 1 KB

Versions: 16

Compression:

Stored size: 1 KB

Contents

class Rat
  attr_accessor :name,
                :level,
                :hp
  
  def initialize(name = 'rat')
    self.name   = name
    self.level  = rand(1..4)
    self.hp     = rand((self.level * 3)..(self.level * 5))
  end
end

m = [Rat.new]

rat_o = m[0]
rat_c = m[0].clone

puts "[initial]"
puts "m[0]  : #{m[0].inspect}"
puts "rat_o : #{rat_o.inspect}"
puts "rat_c : #{rat_c.inspect}"

m[0].hp -= 1

puts "[m[0] - 1hp]"
puts "m[0]  : #{m[0].inspect}"
puts "rat_o : #{rat_o.inspect}"
puts "rat_c : #{rat_c.inspect}"

rat_o.hp -= 1

puts "[rat_o - 1hp]"
puts "m[0]  : #{m[0].inspect}"
puts "rat_o : #{rat_o.inspect}"
puts "rat_c : #{rat_c.inspect}"

rat_c.hp -= 1

puts "[rat_c - 1hp]"
puts "m[0]  : #{m[0].inspect}"
puts "rat_o : #{rat_o.inspect}"
puts "rat_c : #{rat_c.inspect}"

rat_c2 = m[0].clone

puts "[rat_c2 created from m[0]]"
puts "m[0]  : #{m[0].inspect}"
puts "rat_o : #{rat_o.inspect}"
puts "rat_c : #{rat_c.inspect}"
puts "rat_c2: #{rat_c2.inspect}"

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
gemwarrior-0.15.20 tests/test-class/test-class.rb
gemwarrior-0.15.19 tests/test-class/test-class.rb
gemwarrior-0.15.18 tests/test-class/test-class.rb
gemwarrior-0.15.17 tests/test-class/test-class.rb
gemwarrior-0.15.16 tests/test-class/test-class.rb
gemwarrior-0.15.15 tests/test-class/test-class.rb
gemwarrior-0.15.14 tests/test-class/test-class.rb
gemwarrior-0.15.13 tests/test-class/test-class.rb
gemwarrior-0.15.12 tests/test-class/test-class.rb
gemwarrior-0.15.11 tests/test-class/test-class.rb
gemwarrior-0.15.10 tests/test-class/test-class.rb
gemwarrior-0.15.9 tests/test-class/test-class.rb
gemwarrior-0.15.8 tests/test-class/test-class.rb
gemwarrior-0.15.7 tests/test-class/test-class.rb
gemwarrior-0.15.6 tests/test-class/test-class.rb
gemwarrior-0.15.5 tests/test-class/test-class.rb