Method: Teacup::Stylesheet#initialize

Defined in:
lib/teacup/stylesheet.rb

#initialize(name = nil, &block) ⇒ Stylesheet

Create a new Stylesheet.

If a name is provided then a new constant will be created using that name.

Examples:

Teacup::Stylesheet.new(:ipadvertical) do
  import :ipadbase
  style :continue_button,
     top: 50
end

Teacup::Stylesheet[:ipadvertical].query(:continue_button)
# => {top: 50}

Parameters:

  • name,

    The (optional) name to give.

  • &block,

    The body of the Stylesheet instance_eval’d.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/teacup/stylesheet.rb', line 105

def initialize(name=nil, &block)
  if name
    @name = name.to_sym
    if Teacup::Stylesheet[@name]
      NSLog("TEACUP WARNING: A stylesheet with the name #{@name.inspect} has already been created.")
    end
    Teacup::Stylesheet[@name] = self
  end

  # we just store the block for now, because some classes are not "ready"
  # for instance, calling `UIFont.systemFontOfSize()` will cause the
  # application to crash.  We will lazily-load this block in `query`, and
  # then set it to nil.
  @block = block
end