module NarouAgent::UrlHelper

Constants

NCODE_PATTERN

Public Class Methods

extract_part_id(url) click to toggle source
# File lib/narou_agent/url_helper.rb, line 15
def extract_part_id(url)
  url[%r{noveldataid/(\d+)}, 1]
end
ncode_to_i(ncode) click to toggle source

See syosetu.com/bbstopic/top/topicid/2733/

# File lib/narou_agent/url_helper.rb, line 7
def ncode_to_i(ncode)
  match     = ncode.upcase.match(NCODE_PATTERN)
  alphabets = ('A'..'Z').to_a
  match[:digits].to_i + match[:alphabets].chars.reverse.each_with_index.inject(0) do |sum, (alphabet, i)|
    sum += 9999 * alphabets.index(alphabet) * (alphabets.size ** i)
  end
end

Private Instance Methods

delete_part_url(ncode, id) click to toggle source
# File lib/narou_agent/url_helper.rb, line 42
def delete_part_url(ncode, id)
  "#{base_url}/usernoveldatamanage/deleteconfirm/ncode/#{UrlHelper.ncode_to_i(ncode)}/noveldataid/#{id}/"
end
edit_part_url(ncode, id) click to toggle source
# File lib/narou_agent/url_helper.rb, line 38
def edit_part_url(ncode, id)
  "#{base_url}/usernoveldatamanage/updateinput/ncode/#{UrlHelper.ncode_to_i(ncode)}/noveldataid/#{id}/"
end
login_url() click to toggle source
# File lib/narou_agent/url_helper.rb, line 22
def login_url
  "#{base_url}/login/input/"
end
new_part_url(ncode) click to toggle source
# File lib/narou_agent/url_helper.rb, line 34
def new_part_url(ncode)
  "#{base_url}/usernovelmanage/ziwainput/ncode/#{UrlHelper.ncode_to_i(ncode)}}/"
end
novel_url(ncode) click to toggle source
# File lib/narou_agent/url_helper.rb, line 26
def novel_url(ncode)
  "#{base_url}/usernovelmanage/top/ncode/#{UrlHelper.ncode_to_i(ncode)}/"
end
part_url(ncode, id) click to toggle source
# File lib/narou_agent/url_helper.rb, line 30
def part_url(ncode, id)
  "#{base_url}/usernoveldatamanage/top/ncode/#{UrlHelper.ncode_to_i(ncode)}/noveldataid/#{id}/"
end