Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

readme fix

  • Loading branch information...
commit 9592958253e01e793a277f3a7759529ece42934a 1 parent 5c91e6b
Ernest Bursa authored
Showing with 17 additions and 9 deletions.
  1. +9 −1 README.rdoc
  2. +8 −8 lib/ruby-network-manager.rb
10 README.rdoc
View
@@ -7,7 +7,15 @@ Using *bundler* add **ruby-network-manager** to your gemfile
gem 'ruby-network-manager', git: 'git://github.com/swistaczek/ruby-network-manager.git'
-== Contributing to ruby-network-manager
+== Usage
+To fetch all available modems call:
+
+ @network_mgr = NetworkManager.new
+ @devices = @network_mgr.modem_devices
+
+*modem_devices** method returns array of *NetworkManager::Modem#Object*.
+
+== Contributing to ruby-network-manager
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
16 lib/ruby-network-manager.rb
View
@@ -2,7 +2,7 @@
require 'network_manager/modem'
class NetworkManager
- attr_reader :service, :bus_path, :mm_object
+ attr_reader :modem_service, :modem_bus_path
DBUS_PROPERTIES = 'freedesktop.DBus.Properties'
MM_DBUS_SERVICE = 'org.freedesktop.ModemManager'
@@ -16,15 +16,15 @@ class NetworkManager
def initialize(opts = {})
set_options opts
@bus = DBus::SystemBus.instance
- @mm_service = @bus[@service]
- @mm_object = @mm_service.object(@bus_path)
- @mm_object.introspect
end
# Discover all enabled devices
- def devices(opts = {})
- @devices = []
+ def modem_devices(opts = {})
+ @mm_service ||= @bus[@modem_service]
+ @mm_object ||= @mm_service.object(@modem_bus_path)
@mm_object.introspect
+
+ @devices = []
NetworkManager::Modem.fetch(@mm_object.EnumerateDevices(), service: @mm_service)
end
@@ -35,8 +35,8 @@ class << self
protected
def set_options(opts = {})
- @service ||= MM_DBUS_SERVICE || 'org.freedesktop.ModemManager'
- @bus_path ||= '/org/freedesktop/ModemManager'
+ @modem_service ||= MM_DBUS_SERVICE || 'org.freedesktop.ModemManager'
+ @modem_bus_path ||= '/org/freedesktop/ModemManager'
args.each do |k,v|
instance_variable_set("@#{k}", v) unless v.nil?
Please sign in to comment.
Something went wrong with that request. Please try again.