Class: Wee::Brush

Inherits:
Object show all
Defined in:
lib/wee/html_brushes.rb

Direct Known Subclasses

GenericTagBrush, GenericTextBrush, Page

Defined Under Namespace

Classes: ActionInputTag, AnchorTag, CheckboxTag, FileUploadTag, FormTag, GenericEncodedTextBrush, GenericSingleTagBrush, GenericTagBrush, GenericTextBrush, HiddenInputTag, ImageButtonTag, ImageTag, InputTag, JavascriptTag, Page, PasswordInputTag, RadioButtonTag, RadioGroup, SelectListTag, SelectOptionTag, SubmitButtonTag, TableDataTag, TableHeaderTag, TableRowTag, TableTag, TextAreaTag, TextInputTag

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#canvasObject

Returns the value of attribute canvas.



4
5
6
# File 'lib/wee/html_brushes.rb', line 4

def canvas
  @canvas
end

#documentObject

Returns the value of attribute document.



4
5
6
# File 'lib/wee/html_brushes.rb', line 4

def document
  @document
end

Class Method Details

.nesting?Boolean

Returns:

  • (Boolean)


29
# File 'lib/wee/html_brushes.rb', line 29

def self.nesting?() true end

Instance Method Details

#closeObject



25
26
27
# File 'lib/wee/html_brushes.rb', line 25

def close
  with if @document
end

#setup(canvas, document) ⇒ Object

This method is called right after #initialize. It’s only here to simplify the implementation of Brushes, mainly to avoid passing all those arguments to super.

There is a bit of redundancy with canvas and document here. It’s there to avoid method calls.

A brush is considered to be closed, when @document is nil.



15
16
17
18
# File 'lib/wee/html_brushes.rb', line 15

def setup(canvas, document)
  @canvas = canvas
  @document = document
end

#with(*args, &block) ⇒ Object



20
21
22
23
# File 'lib/wee/html_brushes.rb', line 20

def with(*args, &block)
  @canvas.nest(&block) if block
  @document = @canvas = nil
end