Module: Tsundere
- Defined in:
- lib/tsundere/imouto.rb,
lib/tsundere.rb,
lib/tsundere/class_methods.rb,
lib/tsundere/instance_methods.rb
Overview
tsundere instance module
Defined Under Namespace
Modules: ClassMethods Classes: Imouto
Class Method Summary collapse
Instance Method Summary collapse
-
#dere_for?(lvl, meth) ⇒ Boolean
tsundere_for.
-
#tsun_for(lvl) ⇒ Object
dere_for?.
- #tsundere_for(duck) ⇒ Object
Class Method Details
.included(base) ⇒ Object
9 10 11 |
# File 'lib/tsundere.rb', line 9 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#dere_for?(lvl, meth) ⇒ Boolean
tsundere_for
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tsundere/instance_methods.rb', line 10 def dere_for? lvl, meth return false if lvl.nil? if self.class.rank_table[lvl].is_a? Array and self.class.rank_table[lvl].include? meth return true else level = self.class.rank_table[lvl.to_sym] if lvl.is_a? Symbol or lvl.is_a? String level ||= lvl start_ind = self.class.[:looker][:array].binary_search_raw([level, [meth]], :left => true) { |a1, a2| a1.first <=> a2.first } flag = false (start_ind+1).times do |n| flag = self.class.[:looker][:array][n].last.include? meth break flag if flag end # times return flag end # if-else end |
#tsun_for(lvl) ⇒ Object
dere_for?
27 28 29 30 |
# File 'lib/tsundere/instance_methods.rb', line 27 def tsun_for lvl fail_msg = self.class.fail_table[lvl] fail_msg ||= "Sorry #{lvl}, access is denied!" end |