Class: Cul::Fedora::Server
- Inherits:
-
Object
- Object
- Cul::Fedora::Server
- Defined in:
- lib/cul-fedora/server.rb
Instance Attribute Summary collapse
-
#riquery ⇒ Object
readonly
Returns the value of attribute riquery.
-
#riurl ⇒ Object
readonly
Returns the value of attribute riurl.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Server
constructor
A new instance of Server.
- #item(uri) ⇒ Object
- #logger ⇒ Object
- #request(options = {}) ⇒ Object
- #request_path(options = {}) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Server
Returns a new instance of Server.
13 14 15 16 17 18 19 |
# File 'lib/cul-fedora/server.rb', line 13 def initialize(*args) = args. @riurl = [:riurl] || ["riurl"] || raise(ArgumentError, "Must provide riurl argument") @riquery = [:riquery] || ["riquery"] || raise(ArgumentError, "Must provide riquery argument") @hc = [:http_client] || ["http_client"] @logger = [:logger] || ["logger"] end |
Instance Attribute Details
#riquery ⇒ Object (readonly)
Returns the value of attribute riquery.
11 12 13 |
# File 'lib/cul-fedora/server.rb', line 11 def riquery @riquery end |
#riurl ⇒ Object (readonly)
Returns the value of attribute riurl.
11 12 13 |
# File 'lib/cul-fedora/server.rb', line 11 def riurl @riurl end |
Instance Method Details
#item(uri) ⇒ Object
25 26 27 |
# File 'lib/cul-fedora/server.rb', line 25 def item(uri) Item.new(:server => self, :uri => uri, :logger => logger) end |
#logger ⇒ Object
21 22 23 |
# File 'lib/cul-fedora/server.rb', line 21 def logger @logger ||= Logger.new(STDOUT) end |
#request(options = {}) ⇒ Object
29 30 31 |
# File 'lib/cul-fedora/server.rb', line 29 def request(= {}) http_client.get_content(*request_path()) end |
#request_path(options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cul-fedora/server.rb', line 33 def request_path( = {}) sdef = .delete(:sdef).to_s pid = .delete(:pid).to_s request = (.delete(:request) || "").to_s method = (.delete(:method) || "/get").to_s sdef = "/" + sdef unless sdef.empty? pid = "/" + pid unless pid.empty? request = "/" + request.to_s uri = @riurl + method + pid + sdef + request query = return [uri, query] end |