Class: MyMachineAnime44
- Inherits:
-
Object
- Object
- MyMachineAnime44
- Includes:
- MyMachine
- Defined in:
- lib/lib/machine.rb
Instance Attribute Summary collapse
-
#savedir ⇒ Object
readonly
Returns the value of attribute savedir.
Instance Method Summary collapse
-
#go ⇒ Object
machine go to run eventmachine.
-
#initialize(args = { }) ⇒ MyMachineAnime44
constructor
A new instance of MyMachineAnime44.
-
#setupjobs ⇒ Object
setup jobs.
-
#should_stop_machine? ⇒ Boolean
Machineは終了すべきか?.
Methods included from MyMachine
Constructor Details
#initialize(args = { }) ⇒ MyMachineAnime44
Returns a new instance of MyMachineAnime44.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/lib/machine.rb', line 137 def initialize(args={ }) require 'eventmachine' super(args) args[:savedir] ||= "#{ENV['HOME']}/Desktop/video" @savedir = args[:savedir] begin Dir::mkdir(@savedir, 0777) rescue => ex warn ex end @args = args @args[:recursive] ||= 2 @gaman = 0; end |
Instance Attribute Details
#savedir ⇒ Object (readonly)
Returns the value of attribute savedir.
135 136 137 |
# File 'lib/lib/machine.rb', line 135 def savedir @savedir end |
Instance Method Details
#go ⇒ Object
machine go to run eventmachine
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/lib/machine.rb', line 153 def go EM.run do EM.add_periodic_timer(0.00001) do # print "loop".green if should_stop_machine? EM.stop end @queue.pop.run unless @queue.empty? end end puts "End of fetch".green.bold end |
#setupjobs ⇒ Object
setup jobs
167 168 169 170 171 172 173 174 175 |
# File 'lib/lib/machine.rb', line 167 def setupjobs ajob = MyJobAnime44 .new( :machine => self, :recursive => @args[:recursive], :debug => @debug, ) @queue.push ajob end |
#should_stop_machine? ⇒ Boolean
Machineは終了すべきか?
178 179 180 181 182 183 |
# File 'lib/lib/machine.rb', line 178 def should_stop_machine? @gaman += 1 if @queue.size < 3 if @gaman > 1000 return true end end |