Class: BitlbeeConfig::Channel
- Inherits:
-
Object
- Object
- BitlbeeConfig::Channel
- Includes:
- XmlBuildable
- Defined in:
- lib/bitlbee_config/channel.rb
Overview
A channel on the bitlbee server. Can either be a control channel, in which you issue commands to the BitlBee root user, or a chat channel, which is a multi contact conversation
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
-
.from_xml(xml) ⇒ BitlbeeConfig::Channel
The newly created channel.
Instance Method Summary collapse
- #build_xml(xml_builder) ⇒ Object
-
#initialize(options = {}) ⇒ Channel
constructor
A new instance of Channel.
Methods included from XmlBuildable
Constructor Details
#initialize(options = {}) ⇒ Channel
Returns a new instance of Channel.
32 33 34 35 36 |
# File 'lib/bitlbee_config/channel.rb', line 32 def initialize( = {}) @name = .delete(:name) @type = .delete(:type) @settings = || {} end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/bitlbee_config/channel.rb', line 6 def name @name end |
#settings ⇒ Object
Returns the value of attribute settings.
6 7 8 |
# File 'lib/bitlbee_config/channel.rb', line 6 def settings @settings end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/bitlbee_config/channel.rb', line 6 def type @type end |
Class Method Details
.from_xml(xml) ⇒ BitlbeeConfig::Channel
Returns The newly created channel.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bitlbee_config/channel.rb', line 11 def from_xml(xml) new_channel = {} # get setting attributes xml.attributes.each do |att_name, att_value| new_channel[att_name.to_sym] = att_value.text end # get setting children xml.children.select { |node| node.is_a?(Nokogiri::XML::Element) }.each do |setting_element| new_channel[setting_element.values.first.to_sym] = setting_element.text end BitlbeeConfig::Channel.new(new_channel) end |
Instance Method Details
#build_xml(xml_builder) ⇒ Object
39 40 41 |
# File 'lib/bitlbee_config/channel.rb', line 39 def build_xml(xml_builder) (xml_builder, name: @name, type: @type) end |