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.



241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/rabbit/theme/applier.rb', line 241

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)



446
447
448
449
450
451
452
# File 'lib/rabbit/theme/applier.rb', line 446

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

Instance Method Details

#[](name) ⇒ Object



309
310
311
# File 'lib/rabbit/theme/applier.rb', line 309

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

#apply_theme(name) ⇒ Object



255
256
257
258
259
260
261
262
263
# File 'lib/rabbit/theme/applier.rb', line 255

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



265
266
267
# File 'lib/rabbit/theme/applier.rb', line 265

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

#normalized_heightObject



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

def normalized_height
  NORMALIZED_HEIGHT / Canvas::INTERNAL_DPI
end

#normalized_size(s) ⇒ Object



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

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

#normalized_widthObject



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

def normalized_width
  NORMALIZED_WIDTH / Canvas::INTERNAL_DPI
end

#normalized_x(sx) ⇒ Object



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

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

#normalized_y(sy) ⇒ Object



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

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

#screen_size(n) ⇒ Object



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

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

#screen_x(nx) ⇒ Object



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

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

#screen_y(ny) ⇒ Object



305
306
307
# File 'lib/rabbit/theme/applier.rb', line 305

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

#to_container(obj) ⇒ Object



269
270
271
272
273
274
275
# File 'lib/rabbit/theme/applier.rb', line 269

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