Class: Spigoter::PluginSpigot

Inherits:
Plugin
  • Object
show all
Defined in:
lib/spigoter/webapi/spigot.rb

Overview

Class that represent a devBukkit plugin.

Author:

Instance Method Summary collapse

Methods inherited from Plugin

#file, list, #main_page

Constructor Details

#initialize(website) ⇒ PluginSpigot

Returns a new instance of PluginSpigot.



8
9
10
11
# File 'lib/spigoter/webapi/spigot.rb', line 8

def initialize(website)
  raise "Bad URL #{website}" if website.match(%r{https://www.spigotmc.org/resources/[a-z0-9\-]+/?}).nil?
  super(website)
end

Instance Method Details

#download_urlObject



13
14
15
16
17
# File 'lib/spigoter/webapi/spigot.rb', line 13

def download_url
  return @download_url unless @download_url.nil?
  uri = /<a href="(?<download_url>resources.+)" class="inner">/.match(@main_page)[:download_url]
  @download_url = "https://www.spigotmc.org/#{uri}"
end

#nameObject



24
25
26
27
# File 'lib/spigoter/webapi/spigot.rb', line 24

def name
  return @name unless @name.nil?
  @name = /<h1>(?<name>.+?)\s*<span class="muted">/.match(@main_page)[:name]
end

#versionObject



19
20
21
22
# File 'lib/spigoter/webapi/spigot.rb', line 19

def version
  return @version unless @version.nil?
  @version = %r{class="muted">(?<version>.+)</span>}.match(@main_page)[:version]
end