Class: Kaede::DBus::Program

Inherits:
DBus::Object
  • Object
show all
Includes:
Properties
Defined in:
lib/kaede/dbus/program.rb

Constant Summary collapse

PATH =
'/cc/wanko/kaede1/program'
PROPERTY_INTERFACE =
'org.freedesktop.DBus.Properties'
INTROSPECT_INTERFACE =
'org.freedesktop.DBus.Introspectable'
PROGRAM_INTERFACE =
'cc.wanko.kaede1.Program'

Instance Method Summary collapse

Methods included from Properties

#get_properties, #get_property, included, #raise_access_denied!, #raise_unknown_interface!, #raise_unknown_property!, #xml_for_dbus_properties, #xml_for_properties

Constructor Details

#initialize(program, enqueued_at) ⇒ Program

Returns a new instance of Program.



14
15
16
17
18
# File 'lib/kaede/dbus/program.rb', line 14

def initialize(program, enqueued_at)
  super("#{PATH}/#{program.pid}")
  @program = program
  @enqueued_at = enqueued_at
end

Instance Method Details

#propertiesObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/kaede/dbus/program.rb', line 46

def properties
  @properties ||= {
    'Pid' => @program.pid,
    'Tid' => @program.tid,
    'StartTime' => @program.start_time.iso8601,
    'EndTime' => @program.end_time.iso8601,
    'ChannelName' => @program.channel_name,
    'ChannelForSyoboi' => @program.channel_for_syoboi,
    'ChannelForRecorder' => @program.channel_for_recorder,
    'Count' => @program.count,
    'StartOffset' => @program.start_offset,
    'SubTitle' => @program.subtitle,
    'Title' => @program.title,
    'Comment' => @program.comment,
    'EnqueuedAt' => @enqueued_at.iso8601,
  }
end

#to_xmlObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kaede/dbus/program.rb', line 24

def to_xml
  Nokogiri::XML::Builder.new do |xml|
    xml.doc.create_internal_subset(
      'node',
      '-//freedesktop//DTD D-BUS Object Introspection 1.0//EN',
      'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd',
    )
    xml.node do
      xml.interface(name: INTROSPECT_INTERFACE) do
        xml.method_(name: 'Introspect') do
          xml.arg(name: 'data', direction: 'out', type: 's')
        end
      end

      xml_for_properties(xml)
    end
  end.to_xml
end