Class: ContentWidget

Inherits:
Object
  • Object
show all
Includes:
EnumField::DefineEnum
Defined in:
app/models/content_widget.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, regexp, sample, is_cells = false) ⇒ ContentWidget

Returns a new instance of ContentWidget.



8
9
10
11
12
13
14
# File 'app/models/content_widget.rb', line 8

def initialize(code, regexp, sample, is_cells = false)
  @code = code.to_sym
  @regexp = regexp.is_a?(Regexp) ? regexp : Regexp.new(regexp)
  @sample = sample
  @file = ['content_widgets', code].join('/')
  @is_cells = is_cells
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'app/models/content_widget.rb', line 6

def code
  @code
end

#fileObject (readonly)

Returns the value of attribute file.



6
7
8
# File 'app/models/content_widget.rb', line 6

def file
  @file
end

#regexpObject (readonly)

Returns the value of attribute regexp.



6
7
8
# File 'app/models/content_widget.rb', line 6

def regexp
  @regexp
end

#sampleObject (readonly)

Returns the value of attribute sample.



6
7
8
# File 'app/models/content_widget.rb', line 6

def sample
  @sample
end

Instance Method Details

#cells?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/models/content_widget.rb', line 16

def cells?
  @is_cells
end

#titleObject



20
21
22
# File 'app/models/content_widget.rb', line 20

def title
  I18n.t(code, scope: [:content_widget])
end