Class: Gitter::Header

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grid, *args) ⇒ Header

Returns a new instance of Header.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
# File 'lib/gitter/header.rb', line 10

def initialize grid, *args
  opts = args.extract_options!
  raise ArgumentError, 'too many arguments' if args.size > 1
  @grid = grid
  @content = args.first
  @column = opts.delete(:column){nil}
  @html_options = opts
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



8
9
10
# File 'lib/gitter/header.rb', line 8

def column
  @column
end

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/gitter/header.rb', line 8

def content
  @content
end

#gridObject (readonly)

Returns the value of attribute grid.



8
9
10
# File 'lib/gitter/header.rb', line 8

def grid
  @grid
end

#html_optionsObject (readonly)

Returns the value of attribute html_options.



8
9
10
# File 'lib/gitter/header.rb', line 8

def html_options
  @html_options
end

Class Method Details

.blankObject



4
5
6
# File 'lib/gitter/header.rb', line 4

def self.blank
  new :blank, false
end

Instance Method Details

#labelObject



19
20
21
22
23
24
25
# File 'lib/gitter/header.rb', line 19

def label
  @label ||= case content
	when false then ''
	when Symbol then grid.translate(:headers, name)
    else content
  end
end


27
28
29
30
31
32
33
# File 'lib/gitter/header.rb', line 27

def link *args
  if column
    column.link label, *args
  else
	label
  end
end

#nameObject



35
36
37
# File 'lib/gitter/header.rb', line 35

def name
  @name ||= Symbol === content ? content : 'n/a'
end

#to_sObject



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

def to_s
  "Header(#{name},html_options=#{html_options},#{column ? ',col':''},label=#{label})"
end