Class: Rabbit::Theme::Applier

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
DirtyCount, Element, GetText, 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 GetText

GetText::DOMAIN

Constants included from DirtyCount

DirtyCount::TOO_DIRTY

Instance Method Summary collapse

Methods included from GetText

included

Methods included from DirtyCount

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

Methods included from Searcher

_collect_theme, absolute_path?, #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.



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

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)



452
453
454
455
456
457
458
# File 'lib/rabbit/theme/applier.rb', line 452

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

Instance Method Details

#[](name) ⇒ Object



315
316
317
# File 'lib/rabbit/theme/applier.rb', line 315

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

#apply_theme(name) ⇒ Object



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

def apply_theme(name)
  entry = find_theme(name)
  src = File.open(entry.theme_file, "r:utf-8") do |f|
    f.read
  end
  in_theme(entry) do
    instance_eval(normalize_source(src), entry.theme_file)
  end
end

#make_container(ary) ⇒ Object



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

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

#normalized_heightObject



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

def normalized_height
  NORMALIZED_HEIGHT / Canvas::INTERNAL_DPI
end

#normalized_size(s) ⇒ Object



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

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

#normalized_widthObject



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

def normalized_width
  NORMALIZED_WIDTH / Canvas::INTERNAL_DPI
end

#normalized_x(sx) ⇒ Object



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

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

#normalized_y(sy) ⇒ Object



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

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

#screen_size(n) ⇒ Object



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

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

#screen_x(nx) ⇒ Object



307
308
309
# File 'lib/rabbit/theme/applier.rb', line 307

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

#screen_y(ny) ⇒ Object



311
312
313
# File 'lib/rabbit/theme/applier.rb', line 311

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

#to_container(obj) ⇒ Object



275
276
277
278
279
280
281
# File 'lib/rabbit/theme/applier.rb', line 275

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