class NarouAgent
Constants
- ActionFailedError
- BASE_URL
- DEFAULT_WAIT_DURATION
- Error
- NotLoggedInError
- VERSION
Attributes
base_url[R]
driver[R]
Public Class Methods
new(base_url: BASE_URL, driver: Selenium::WebDriver.for(:chrome, options: Selenium::WebDriver::Chrome::Options.new.tap(&:headless!)))
click to toggle source
# File lib/narou_agent.rb, line 20 def initialize(base_url: BASE_URL, driver: Selenium::WebDriver.for(:chrome, options: Selenium::WebDriver::Chrome::Options.new.tap(&:headless!))) @base_url = base_url @driver = driver @logged_in = false end
Public Instance Methods
create_part(ncode:, subtitle:, body:, date: nil, wait_duration: DEFAULT_WAIT_DURATION)
click to toggle source
# File lib/narou_agent.rb, line 35 def create_part(ncode:, subtitle:, body:, date: nil, wait_duration: DEFAULT_WAIT_DURATION) raise NotLoggedInError unless logged_in? Actions::CreatePart.new(self).run(ncode, subtitle, body, date, wait_duration) end
delete_part(ncode:, part_id:)
click to toggle source
# File lib/narou_agent.rb, line 45 def delete_part(ncode:, part_id:) raise NotLoggedInError unless logged_in? Actions::DeletePart.new(self).run(ncode, part_id) end
logged_in?()
click to toggle source
# File lib/narou_agent.rb, line 26 def logged_in? @logged_in end
login!(id:, password:)
click to toggle source
# File lib/narou_agent.rb, line 30 def login!(id:, password:) Actions::Login.new(self).run(id, password) @logged_in = true end
update_part(ncode:, part_id:, subtitle:, body:, date: nil)
click to toggle source
# File lib/narou_agent.rb, line 40 def update_part(ncode:, part_id:, subtitle:, body:, date: nil) raise NotLoggedInError unless logged_in? Actions::UpdatePart.new(self).run(ncode, part_id, subtitle, body, date) end