Class: RubDev::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/rubdev/device.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_devnum(context, type, devnum) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/rubdev/device.rb', line 54

def from_devnum (context, type, devnum)
  return nil unless context.is_a?(Context) and type.is_a?(String) and
    type.bytesize == 1 and devnum.is_a?(Integer)

  self.allocate.tap {|d|
    d.instance_variable_set(:@pointer, RubDev::C.udev_device_new_from_devnum(context.to_c, type, devnum))
  }
end

.from_environment(context) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/rubdev/device.rb', line 71

def from_environment (context)
  return nil unless context.is_a?(Context)

  self.allocate.tap {|d|
    d.instance_variable_set(:@pointer, RubDev::C.udev_device_new_from_environment(context.to_c))
  }
end

.from_subsystem_sysname(context, subsystem, sysname) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/rubdev/device.rb', line 63

def from_subsystem_sysname (context, subsystem, sysname)
  return nil unless context.is_a?(Context) and subsystem.is_a?(String) and sysname.is_a?(String)

  self.allocate.tap {|d|
    d.instance_variable_set(:@pointer, RubDev::C.udev_device_new_from_subsystem_sysname(context.to_c, subsystem, sysname))
  }
end

.from_syspath(context, syspath) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/rubdev/device.rb', line 46

def from_syspath (context, syspath)
  return nil unless context.is_a?(Context) and syspath.is_a?(String)

  self.allocate.tap {|d|
    d.instance_variable_set(:@pointer, RubDev::C.udev_device_new_from_syspath(context.to_c, syspath))
  }
end

Instance Method Details

#actionObject



151
152
153
# File 'lib/rubdev/device.rb', line 151

def action
  RubDev::C.udev_device_get_action(@pointer)
end

#contextObject



37
38
39
40
41
# File 'lib/rubdev/device.rb', line 37

def context
  Context.allocate.tap {|c|
    c.instance_variable_set(:@pointer, RubDev::C.udev_device_get_udev(@pointer))
  }
end


126
127
128
# File 'lib/rubdev/device.rb', line 126

def devlinks
  List.new(RubDev::C.udev_device_get_devlinks_list_entry(@pointer))
end

#devnodeObject



116
117
118
# File 'lib/rubdev/device.rb', line 116

def devnode
  RubDev::C.udev_device_get_devnode(@pointer)
end

#devnumObject



147
148
149
# File 'lib/rubdev/device.rb', line 147

def devnum
  RubDev::C.udev_device_get_devnum(@pointer)
end

#devpathObject



92
93
94
# File 'lib/rubdev/device.rb', line 92

def devpath
  RubDev::C.udev_device_get_devpath(@pointer)
end

#devtypeObject



100
101
102
# File 'lib/rubdev/device.rb', line 100

def devtype
  RubDev::C.udev_device_get_devtype(@pointer)
end

#driverObject



143
144
145
# File 'lib/rubdev/device.rb', line 143

def driver
  RubDev::C.udev_device_get_driver(@pointer)
end

#initialized?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/rubdev/device.rb', line 121

def initialized?
  !RubDev::C.udev_device_get_is_initialized(@pointer).zero?
end

#parentObject



80
81
82
83
84
# File 'lib/rubdev/device.rb', line 80

def parent
  Device.allocate.tap {|i|
    i.instance_variable_set(:@pointer, RubDev::C.udev_device_get_parent(@pointer))
  }
end

#parent_with_subsystem_devtype(subsystem, devtype) ⇒ Object



86
87
88
89
90
# File 'lib/rubdev/device.rb', line 86

def parent_with_subsystem_devtype (subsystem, devtype)
  Device.allocate.tap {|i|
    i.instance_variable_set(:@pointer, RubDev::C.udev_device_get_parent_with_subsytem_devtype(@pointer, subsystem, devtype))
  }
end

#propertiesObject



130
131
132
# File 'lib/rubdev/device.rb', line 130

def properties
  List.new(RubDev::C.udev_device_get_properties_list_entry(@pointer))
end

#property(what) ⇒ Object Also known as: []



138
139
140
# File 'lib/rubdev/device.rb', line 138

def property (what)
  RubDev::C.udev_device_get_property_value(@pointer, what.to_s)
end

#refObject



27
28
29
30
# File 'lib/rubdev/device.rb', line 27

def ref
  RubDev::C.udev_device_ref(@pointer)
  self
end

#seqnumObject



165
166
167
# File 'lib/rubdev/device.rb', line 165

def seqnum
  RubDev::C.udev_device_get_seqnum(@pointer)
end

#subsystemObject



96
97
98
# File 'lib/rubdev/device.rb', line 96

def subsystem
  RubDev::C.udev_device_get_subsystem(@pointer)
end

#sysattr(what) ⇒ Object



155
156
157
# File 'lib/rubdev/device.rb', line 155

def sysattr (what)
  RubDev::C.udev_device_get_sysattr_value(@pointer, what)
end

#sysattrsObject



160
161
162
# File 'lib/rubdev/device.rb', line 160

def sysattrs
  List.new(RubDev::C.udev_device_get_sysattr_list_entry(@pointer))
end

#sysnameObject



108
109
110
# File 'lib/rubdev/device.rb', line 108

def sysname
  RubDev::C.udev_device_get_sysname(@pointer)
end

#sysnumObject



112
113
114
# File 'lib/rubdev/device.rb', line 112

def sysnum
  RubDev::C.udev_device_get_sysnum(@pointer)
end

#syspathObject



104
105
106
# File 'lib/rubdev/device.rb', line 104

def syspath
  RubDev::C.udev_device_get_syspath(@pointer)
end

#tag?(tag) ⇒ Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/rubdev/device.rb', line 176

def tag? (tag)
  !RubDev::C.udev_device_has_tag(tag).zero?
end

#tagsObject



134
135
136
# File 'lib/rubdev/device.rb', line 134

def tags
  List.new(RubDev::C.udev_device_get_tags_list_entry(@pointer))
end

#unrefObject



32
33
34
35
# File 'lib/rubdev/device.rb', line 32

def unref
  RubDev::C.udev_device_unref(@pointer)
  self
end

#usecObject



170
171
172
# File 'lib/rubdev/device.rb', line 170

def usec
  RubDev::C.udev_device_get_usec_since_initialized(@pointer)
end