Class: Computering::Dsl::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/computering/dsl/text.rb

Direct Known Subclasses

Code, Command, Headline, Link, List, Spec

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, buffer = nil) ⇒ Text

Returns a new instance of Text.



11
12
13
14
# File 'lib/computering/dsl/text.rb', line 11

def initialize(text, buffer = nil)
  @text   = text
  @buffer = buffer
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



9
10
11
# File 'lib/computering/dsl/text.rb', line 9

def text
  @text
end

Class Method Details

.from_text(*text) ⇒ Object



3
4
5
6
7
# File 'lib/computering/dsl/text.rb', line 3

def self.from_text(*text)
  text.flatten.map do |t|
    t.strip.split("\n").map { |line| self.new(line) }
  end.flatten
end

Instance Method Details

#[](index) ⇒ Object



16
17
18
# File 'lib/computering/dsl/text.rb', line 16

def [](index)
  text_with_style(@text[index], index) if @text[index]
end

#blank?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/computering/dsl/text.rb', line 31

def blank?
  @text.nil? || @text.strip == ""
end

#bufferObject



27
28
29
# File 'lib/computering/dsl/text.rb', line 27

def buffer
  add_style(@buffer, :buffer) if @buffer
end

#executeObject



20
21
# File 'lib/computering/dsl/text.rb', line 20

def execute
end

#paddingObject



23
24
25
# File 'lib/computering/dsl/text.rb', line 23

def padding
  "   "
end