Class: Blocklist::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/blocklist.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, *lines) ⇒ Block

Returns a new instance of Block.



41
42
43
44
# File 'lib/blocklist.rb', line 41

def initialize(name=nil, *lines)
  self.name = name
  self.lines = lines
end

Instance Attribute Details

#linesObject

Returns the value of attribute lines.



39
40
41
# File 'lib/blocklist.rb', line 39

def lines
  @lines
end

#nameObject

Returns the value of attribute name.



39
40
41
# File 'lib/blocklist.rb', line 39

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



46
47
48
49
50
51
# File 'lib/blocklist.rb', line 46

def ==(other)
  return false unless other.class == self.class
  return false unless other.name == self.name
  return false unless other.lines == self.lines
  true
end

#to_sObject



57
58
59
# File 'lib/blocklist.rb', line 57

def to_s
  "# #{name}\n" + lines.join("\n")
end

#toggle_commentsObject



53
54
55
# File 'lib/blocklist.rb', line 53

def toggle_comments
  lines.each {|line| line.toggle_comment}
end