Changeset 6432

Show
Ignore:
Timestamp:
02/09/08 16:17:50 (5 years ago)
Author:
cho45
Message:

lang/ruby/chokan/branches/citrus/plugins/hatena.rb:

リファクタリング

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/chokan/branches/citrus/plugins/hatena.rb

    r6430 r6432  
    88                case message 
    99                when /\bg:([a-z][a-z\d]*)(?::id:([a-z][a-z0-9_-]{1,30}[a-z0-9]))?/i 
    10                         _, g, id = *Regexp.last_match 
     10                        g, id = Regexp.last_match.captures 
    1111                        id << '/' if id 
    1212                        notice(channel, "http://#{g}.g.hatena.ne.jp/#{id}") 
    1313                when /\b(?:([a-z][a-z\d]*):)?id:([a-z][a-z0-9_-]{1,30}[a-z0-9])/i 
    14                         _, s, id = *Regexp.last_match 
    15                         return unless exist? id 
    16                         s ||= "d" 
    17                         notice(channel, "http://#{s}.hatena.ne.jp/#{id}/") 
     14                        s, id = *Regexp.last_match.captures 
     15                        if exist?(id) 
     16                                notice(channel, "http://#{s || "d"}.hatena.ne.jp/#{id}/") 
     17                        end 
    1818                end 
    1919        end 
     
    6262                it "should check id existance" do 
    6363                        @plugin.exist?("jkondo").should be_true 
    64                         @plugin.exist?("jkondo", 0.001).should be_false 
     64                        @plugin.exist?("jkondo", Float::MIN).should be_false 
    6565                end 
    6666        end