-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
123 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'parser/LibraryParser' | ||
|
||
module M_Library | ||
|
||
def makeMessage_library_empty_seat | ||
parser = LibraryParser.new | ||
data = parser.requestEmptySeatData[0..17] | ||
|
||
text = "◆ 중도 자리 ◆\n\n" | ||
data.each do |librarySeat| | ||
text += "#{librarySeat.name}\n사용/총 좌석: #{librarySeat.total}\n\n" | ||
end | ||
return "#{text.strip}" | ||
end | ||
|
||
def makeMessage_library_time | ||
message = "◆ 자료실 | ||
방학 평일: ~21:00 | ||
휴일: ~17:00 | ||
◆ 열람실 | ||
4열람실: 항시 | ||
나머지: ~24:00 | ||
◆ 편의점 | ||
학기: 08:30 ~ 21:00 | ||
방학: 09:00 ~ 20:00 | ||
주말: 10:00 ~ 19:00" | ||
|
||
return message | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'util/HttpRequester' | ||
require 'LibrarySeat' | ||
|
||
class LibraryParser | ||
|
||
def requestEmptySeatData | ||
doc = HttpRequester.requestNokogiriHtml('http://113.198.32.69/mobile/PW/pw20.php') | ||
data = parseData(doc) | ||
return data | ||
end | ||
|
||
def parseData(doc) | ||
|
||
librarySeats = [] | ||
|
||
trs = doc.css("table.default//tr") | ||
trs.each_with_index do |tr| | ||
unless tr.attribute('bgcolor').to_s == "#ffffff" | ||
next | ||
end | ||
|
||
tds = tr.css("td") | ||
|
||
if tds.length == 3 | ||
name = tds[0].inner_text.strip | ||
total = tds[1].inner_text.strip | ||
spare = tds[2].inner_text.strip | ||
|
||
librarySeats << LibrarySeat.new(name, total, spare) | ||
end | ||
|
||
end | ||
|
||
return librarySeats | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'util/TimeHelper' | ||
|
||
class HttpRequester | ||
def self.requestNokogiriHtml(url) | ||
uri = URI(URI.encode(url)) | ||
req = Net::HTTP::Get.new(uri) | ||
res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) } | ||
doc = Nokogiri::HTML(res.body) | ||
return doc | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class LibrarySeat | ||
|
||
attr_reader :name, :total, :spare | ||
|
||
def initialize(name, total, spare) | ||
@name = name | ||
@total = total | ||
@spare = spare | ||
end | ||
end |