Class: USTC::Dalao

Inherits:
Admirable show all
Defined in:
lib/dalao.rb

Instance Attribute Summary

Attributes inherited from Admirable

#name

Instance Method Summary collapse

Methods inherited from Admirable

#==, #admire, #eql?

Constructor Details

#initialize(name) ⇒ Dalao



25
26
27
# File 'lib/dalao.rb', line 25

def initialize(name)
  super(name)
end

Instance Method Details

#excellent?Boolean



34
35
36
37
38
39
40
41
# File 'lib/dalao.rb', line 34

def excellent?
  s = self.fail?
  s ? 'Failed.' : 'Not failed.'
rescue TypeError => e
  e.to_s
ensure
  puts 'Ensure it\'s excellent.'
end

#fail?Boolean

Raises:

  • (TypeError)


29
30
31
32
# File 'lib/dalao.rb', line 29

def fail?
  raise TypeError, "#{@name} can never fail." if @name.downcase == 'zjx'
  true
end

#to_sObject



43
44
45
# File 'lib/dalao.rb', line 43

def to_s
  "#{self.name} is a dalao. " + self.admire
end