Class: EtherpadLite::Instance
- Inherits:
-
Object
- Object
- EtherpadLite::Instance
- Includes:
- Padded
- Defined in:
- lib/etherpad-lite/models/instance.rb
Overview
A high-level interface to EtherpadLite::Client.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Stores the EtherpadLite::Client object used to power this Instance.
Instance Method Summary collapse
-
#author(mapper, options = {}) ⇒ Object
Returns, creating if necessary, a Author mapped to your foreign system’s author.
-
#create_author(options = {}) ⇒ Object
Creates a new Author.
-
#create_group(options = {}) ⇒ Object
Creates a new Group.
-
#get_author(id) ⇒ Object
Returns an Author with the given id (it is presumed to already exist).
-
#get_group(id) ⇒ Object
Returns a Group with the given id (it is presumed to already exist).
-
#get_session(session_id) ⇒ Object
Returns a Session (presumed to already exist).
-
#group(mapper) ⇒ Object
Returns, creating if necessary, a Group mapped to your foreign system’s group.
-
#group_ids ⇒ Object
Returns an array of all group IDs.
-
#groups ⇒ Object
Returns an array of all Group objects.
-
#initialize(url_or_port, api_key_or_file, api_version = nil) ⇒ Instance
constructor
Instantiate a new Etherpad Lite Instance.
-
#instance ⇒ Object
Returns itself.
-
#pad_ids ⇒ Object
Returns an array of all pad IDs.
-
#pads ⇒ Object
Returns an array of all Pad objects.
Methods included from Padded
Constructor Details
#initialize(url_or_port, api_key_or_file, api_version = nil) ⇒ Instance
Instantiate a new Etherpad Lite Instance. You may pass a full url or just a port number. The api key may be a string or a File object.
19 20 21 |
# File 'lib/etherpad-lite/models/instance.rb', line 19 def initialize(url_or_port, api_key_or_file, api_version=nil) @client = Client.new(url_or_port, api_key_or_file, api_version) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Stores the EtherpadLite::Client object used to power this Instance
15 16 17 |
# File 'lib/etherpad-lite/models/instance.rb', line 15 def client @client end |
Instance Method Details
#author(mapper, options = {}) ⇒ Object
Returns, creating if necessary, a Author mapped to your foreign system’s author
Options:
name => the Author’s name
68 69 70 71 |
# File 'lib/etherpad-lite/models/instance.rb', line 68 def (mapper, ={}) [:mapper] = mapper end |
#create_author(options = {}) ⇒ Object
Creates a new Author. Optionally, you may pass the :mapper option your third party system’s author id. This will allow you to find the Author again later using the same identifier as your foreign system.
Options:
mapper => your foreign author id
name => the Author's name
86 87 88 |
# File 'lib/etherpad-lite/models/instance.rb', line 86 def (={}) Author.create self, end |
#create_group(options = {}) ⇒ Object
Creates a new Group. Optionally, you may pass the :mapper option your third party system’s group id. This will allow you to find your Group again later using the same identifier as your foreign system.
Options:
mapper => your foreign group id
49 50 51 |
# File 'lib/etherpad-lite/models/instance.rb', line 49 def create_group(={}) Group.create self, end |
#get_author(id) ⇒ Object
Returns an Author with the given id (it is presumed to already exist).
74 75 76 |
# File 'lib/etherpad-lite/models/instance.rb', line 74 def (id) Author.new self, id end |
#get_group(id) ⇒ Object
Returns a Group with the given id (it is presumed to already exist).
39 40 41 |
# File 'lib/etherpad-lite/models/instance.rb', line 39 def get_group(id) Group.new self, id end |
#get_session(session_id) ⇒ Object
Returns a Session (presumed to already exist).
91 92 93 |
# File 'lib/etherpad-lite/models/instance.rb', line 91 def get_session(session_id) Session.new self, session_id end |
#group(mapper) ⇒ Object
Returns, creating if necessary, a Group mapped to your foreign system’s group
34 35 36 |
# File 'lib/etherpad-lite/models/instance.rb', line 34 def group(mapper) create_group(:mapper => mapper) end |
#group_ids ⇒ Object
Returns an array of all group IDs
54 55 56 |
# File 'lib/etherpad-lite/models/instance.rb', line 54 def group_ids @client.listAllGroups[:groupIDs] end |
#groups ⇒ Object
Returns an array of all Group objects
59 60 61 |
# File 'lib/etherpad-lite/models/instance.rb', line 59 def groups group_ids.map { |id| Group.new self, id } end |
#instance ⇒ Object
Returns itself
96 |
# File 'lib/etherpad-lite/models/instance.rb', line 96 def instance; self; end |
#pad_ids ⇒ Object
Returns an array of all pad IDs
24 25 26 |
# File 'lib/etherpad-lite/models/instance.rb', line 24 def pad_ids @client.listAllPads[:padIDs] end |