Class: Rabbit::Theme::Applier

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
DirtyCount, Element, Searcher
Defined in:
lib/rabbit/theme/applier.rb

Constant Summary collapse

NORMALIZED_WIDTH =

Those constants are meaningless. :p

91.0 * 96
NORMALIZED_HEIGHT =
67.5 * 96

Constants included from DirtyCount

DirtyCount::TOO_DIRTY

Instance Method Summary collapse

Methods included from DirtyCount

#bit_dirty, #dirty, #dirty?, #dirty_count_clean, #very_dirty

Methods included from Searcher

_collect_theme, #add_image_path, collect_all_theme, collect_image_theme, collect_theme, find_file, find_theme, image_dir, image_load_path, #in_theme, #pop_theme, #push_theme, theme_dir, theme_load_path

Constructor Details

#initialize(theme, &callback) ⇒ Applier

Returns a new instance of Applier.



234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/rabbit/theme/applier.rb', line 234

def initialize(theme, &callback)
  super()
  @theme = theme
  @callback = callback
  dirty_count_clean
  @match_cache = {}
  @current_target = nil
  class << slides
    def elements
      self
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object (private)



439
440
441
442
443
444
445
# File 'lib/rabbit/theme/applier.rb', line 439

def method_missing(meth, *args, &block)
  if @current_target
    @current_target.__send__(meth, *args, &block)
  else
    super
  end
end

Instance Method Details

#[](name) ⇒ Object



302
303
304
# File 'lib/rabbit/theme/applier.rb', line 302

def [](name)
  instance_variable_get("@#{name}")
end

#apply_theme(name) ⇒ Object



248
249
250
251
252
253
254
255
256
# File 'lib/rabbit/theme/applier.rb', line 248

def apply_theme(name)
  entry = find_theme(name)
  src = File.open(entry.theme_file) do |f|
    f.read
  end
  in_theme(entry) do
    instance_eval(normalize_source(src), entry.theme_file)
  end
end

#make_container(ary) ⇒ Object



258
259
260
# File 'lib/rabbit/theme/applier.rb', line 258

def make_container(ary)
  ElementContainer.new(self, ary)
end

#normalized_heightObject



274
275
276
# File 'lib/rabbit/theme/applier.rb', line 274

def normalized_height
  NORMALIZED_HEIGHT / Canvas::INTERNAL_DPI
end

#normalized_size(s) ⇒ Object



278
279
280
# File 'lib/rabbit/theme/applier.rb', line 278

def normalized_size(s)
  ((s / canvas.width.to_f) * normalized_width).ceil
end

#normalized_widthObject



270
271
272
# File 'lib/rabbit/theme/applier.rb', line 270

def normalized_width
  NORMALIZED_WIDTH / Canvas::INTERNAL_DPI
end

#normalized_x(sx) ⇒ Object



282
283
284
# File 'lib/rabbit/theme/applier.rb', line 282

def normalized_x(sx)
  ((sx / canvas.width.to_f) * normalized_width).ceil
end

#normalized_y(sy) ⇒ Object



286
287
288
# File 'lib/rabbit/theme/applier.rb', line 286

def normalized_y(sy)
  ((sy / canvas.height.to_f) * normalized_height).ceil
end

#screen_size(n) ⇒ Object



290
291
292
# File 'lib/rabbit/theme/applier.rb', line 290

def screen_size(n)
  ((canvas.width * n) / normalized_width).ceil
end

#screen_x(nx) ⇒ Object



294
295
296
# File 'lib/rabbit/theme/applier.rb', line 294

def screen_x(nx)
  ((canvas.width * nx) / normalized_width).ceil
end

#screen_y(ny) ⇒ Object



298
299
300
# File 'lib/rabbit/theme/applier.rb', line 298

def screen_y(ny)
  ((canvas.height * ny) / normalized_height).ceil
end

#to_container(obj) ⇒ Object



262
263
264
265
266
267
268
# File 'lib/rabbit/theme/applier.rb', line 262

def to_container(obj)
  if obj.is_a?(ElementContainer)
    obj
  else
    make_container([obj])
  end
end