Module: Ragweed::Wraposx::ThreadInfo::ThreadInfoMixins
- Included in:
- Basic, SchedRr, SchedTimeshare
- Defined in:
- lib/ragweed/wraposx/thread_info.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get(t) ⇒ Object
- #initialize(str = nil) ⇒ Object
- #inspect ⇒ Object
-
#refresh(str) ⇒ Object
(re)loads the data from str.
- #to_s ⇒ Object
Class Method Details
.get(t) ⇒ Object
76 77 78 |
# File 'lib/ragweed/wraposx/thread_info.rb', line 76 def self.get(t) self.new(Ragweed::Wraposx::thread_info_raw(t, self.class.const_get(:FLAVOR))) end |
Instance Method Details
#get(t) ⇒ Object
80 81 82 |
# File 'lib/ragweed/wraposx/thread_info.rb', line 80 def get(t) refresh(Ragweed::Wraposx::vm_region_raw(t, self.class.const_get(:FLAVOR))) end |
#initialize(str = nil) ⇒ Object
46 47 48 |
# File 'lib/ragweed/wraposx/thread_info.rb', line 46 def initialize(str=nil) refresh(str) if (str && !str.empty?) end |
#inspect ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/ragweed/wraposx/thread_info.rb', line 67 def inspect body = lambda do self.class.const_get(:FIELDS).map do |f| "#{f[0]}=#{send(f[0]).to_s}" end.join(", ") end "#<#{self.class.name.split('::').last(2).join('::')} #{body.call}>" end |
#refresh(str) ⇒ Object
(re)loads the data from str
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ragweed/wraposx/thread_info.rb', line 51 def refresh(str) fields = self.class.const_get :FIELDS pp self.class if str and not str.empty? str.unpack(fields.map {|x| x[1]}.join("")).each_with_index do |val, i| raise "i is nil" if i.nil? instance_variable_set "@#{ fields[i][0] }".intern, val end end end |
#to_s ⇒ Object
62 63 64 65 |
# File 'lib/ragweed/wraposx/thread_info.rb', line 62 def to_s fields = self.class.const_get :FIELDS fields.map {|f| send(f[0])}.pack(fields.map {|x| x[1]}.join("")) end |