lib/daigaku/markdown/ruby_doc.rb in daigaku-0.3.0 vs lib/daigaku/markdown/ruby_doc.rb in daigaku-0.4.0

- old
+ new

@@ -1,17 +1,16 @@ require 'cgi' module Daigaku - class Markdown + module Markdown class RubyDoc - - RUBY_DOC_URL = "http://ruby-doc.org".freeze + RUBY_DOC_URL = 'http://ruby-doc.org'.freeze CORE_BASE_URL = "#{RUBY_DOC_URL}/core-#{RUBY_VERSION}".freeze STDLIB_BASE_URL = "#{RUBY_DOC_URL}/stdlib-#{RUBY_VERSION}".freeze - CORE_REGEX = /\(ruby-doc core:\s?(.*)\)/.freeze - STDLIB_REGEX = /\(ruby-doc stdlib:\s?(.*)\)/.freeze + CORE_REGEX = /\(ruby-doc core:\s?(.*)\)/ + STDLIB_REGEX = /\(ruby-doc stdlib:\s?(.*)\)/ class << self def parse(text) new.parse(text) end @@ -84,12 +83,12 @@ def ruby_method(text) method = text.split(/::|#/).last return '' unless downcased?(method) - method_type = text.match(/#/) ? 'i' : 'c' - method_name = CGI.escape(method.strip).gsub('%', '-').gsub(/\A-/, '') + method_type = text =~ /#/ ? 'i' : 'c' + method_name = CGI.escape(method.strip).tr('%', '-').gsub(/\A-/, '') "#method-#{method_type}-#{method_name}" end def select_capitalized(parts) parts.select do |part| @@ -98,9 +97,8 @@ end def downcased?(text) text == text.downcase end - end end end