Module: Shoes::DSL::Text

Included in:
Shoes::DSL
Defined in:
shoes-core/lib/shoes/dsl/text.rb

Overview

DSL methods for displaying text in Shoes applications

See Also:

Instance Method Summary collapse

Instance Method Details

Large banner sized text block.

Parameters:

  • text (String, Array<String>) (defaults to: '')

    string or array of strings to show

  • opts (Hash) (defaults to: {})

Returns:

  • (Shoes::Banner)


# File 'shoes-core/lib/shoes/dsl/text.rb', line 9

#bg(*texts, color) ⇒ Shoes::Span

Displays text in different background color. Intended to be called within another text block.

Examples:

para bg('2', blue)

Returns:



142
143
144
# File 'shoes-core/lib/shoes/dsl/text.rb', line 142

def bg(*texts, color)
  Shoes::Span.new texts,  fill: pattern(color)
end

#caption(text = '', opts = {}) ⇒ Shoes::Caption

Caption sized text block.

Parameters:

  • text (String, Array<String>) (defaults to: '')

    string or array of strings to show

  • opts (Hash) (defaults to: {})

Returns:

  • (Shoes::Caption)


# File 'shoes-core/lib/shoes/dsl/text.rb', line 33

#code(text = '') ⇒ Shoes::Span

Displays with in a monospaced font. Intended to be called within another text block.

Examples:

para code('goto 10')

Returns:



# File 'shoes-core/lib/shoes/dsl/text.rb', line 58

#del(text = '') ⇒ Shoes::Span

Displays with strikethrough. Intended to be called within another text block.

Examples:

para del('nope')

Returns:



# File 'shoes-core/lib/shoes/dsl/text.rb', line 65

#em(text = '') ⇒ Shoes::Span

Displays emphasized text. Intended to be called within another text block.

Examples:

para em('EMPHASIS')

Returns:



# File 'shoes-core/lib/shoes/dsl/text.rb', line 72

#fg(*texts, color) ⇒ Shoes::Span

Displays text in different foreground color. Intended to be called within another text block.

Examples:

para fg('2', blue)

Returns:



132
133
134
# File 'shoes-core/lib/shoes/dsl/text.rb', line 132

def fg(*texts, color)
  Shoes::Span.new texts,  stroke: pattern(color)
end

#ins(text = '') ⇒ Shoes::Span

Displays underlined. Intended to be called within another text block.

Examples:

para ins('such lines, very wow')

Returns:



# File 'shoes-core/lib/shoes/dsl/text.rb', line 79

#inscription(text = '', opts = {}) ⇒ Shoes::Inscription

Small, inscription sized text block.

Parameters:

  • text (String, Array<String>) (defaults to: '')

    string or array of strings to show

  • opts (Hash) (defaults to: {})

Returns:

  • (Shoes::Inscription)


50
51
52
53
54
55
56
# File 'shoes-core/lib/shoes/dsl/text.rb', line 50

%w[banner title subtitle tagline caption para inscription].each do |method|
  define_method method do |*texts|
    styles = pop_style(texts)
    klass = Shoes.const_get(method.capitalize)
    create klass, texts, styles
  end
end

Displays a link within a text block. Intended to be called within another text block.

Examples:

para link('clicky') { alert('clicked') }

Parameters:

  • texts (String, Array<String>)

    string or array of strings to show

  • opts (Hash)

    styling options

  • blk (Proc)

    behavior on link click

Returns:



158
159
160
161
# File 'shoes-core/lib/shoes/dsl/text.rb', line 158

def link(*texts, &blk)
  opts = normalize_style_for_element(Shoes::Link, texts)
  Shoes::Link.new @__app__, texts, opts, blk
end

#para(text = '', opts = {}) ⇒ Shoes::Para

Paragraph sized text block.

Parameters:

  • text (String, Array<String>) (defaults to: '')

    string or array of strings to show

  • opts (Hash) (defaults to: {})

Returns:

  • (Shoes::Para)


# File 'shoes-core/lib/shoes/dsl/text.rb', line 39

#span(*texts, opts) ⇒ Shoes::Span

Displays a subsection of text within a larger text block. Intended to be called within another text block to apply styling.

Examples:

para span('spanner')

Parameters:

  • texts (String, Array<String>)

    string or array of strings to show

  • opts (Hash)

    styling options

Returns:



174
175
176
177
# File 'shoes-core/lib/shoes/dsl/text.rb', line 174

def span(*texts)
  opts = normalize_style_for_element(Shoes::Span, texts)
  Shoes::Span.new texts, opts
end

#strong(text = '') ⇒ Shoes::Span

Displays bolded text. Intended to be called within another text block.

Examples:

para strong('TEXT')

Returns:



# File 'shoes-core/lib/shoes/dsl/text.rb', line 100

#sub(text = '') ⇒ Shoes::Span

Displays as subscript. Intended to be called within another text block.

Examples:

para sub('down here')

Returns:



# File 'shoes-core/lib/shoes/dsl/text.rb', line 86

#subtitle(text = '', opts = {}) ⇒ Shoes::Subtitle

Subtitle sized text block.

Parameters:

  • text (String, Array<String>) (defaults to: '')

    string or array of strings to show

  • opts (Hash) (defaults to: {})

Returns:

  • (Shoes::Subtitle)


# File 'shoes-core/lib/shoes/dsl/text.rb', line 21

#sup(text = '') ⇒ Shoes::Span

Displays as superscript. Intended to be called within another text block.

Examples:

para '2', sup('^1')

Returns:



# File 'shoes-core/lib/shoes/dsl/text.rb', line 93

#tagline(text = '', opts = {}) ⇒ Shoes::Tagline

Tagline sized text block.

Parameters:

  • text (String, Array<String>) (defaults to: '')

    string or array of strings to show

  • opts (Hash) (defaults to: {})

Returns:

  • (Shoes::Tagline)


# File 'shoes-core/lib/shoes/dsl/text.rb', line 27

#title(text = '', opts = {}) ⇒ Shoes::Title

Title sized text block.

Parameters:

  • text (String, Array<String>) (defaults to: '')

    string or array of strings to show

  • opts (Hash) (defaults to: {})

Returns:

  • (Shoes::Title)


# File 'shoes-core/lib/shoes/dsl/text.rb', line 15