Class: Bioinform::PrettyMatrixFormatter
- Inherits:
-
Object
- Object
- Bioinform::PrettyMatrixFormatter
- Defined in:
- lib/bioinform/formatters/pretty_matrix_formatter.rb
Instance Attribute Summary collapse
-
#letters_as_rows ⇒ Object
readonly
Returns the value of attribute letters_as_rows.
-
#with_name ⇒ Object
readonly
Returns the value of attribute with_name.
Instance Method Summary collapse
- #format(motif) ⇒ Object
-
#initialize(options = {}) ⇒ PrettyMatrixFormatter
constructor
A new instance of PrettyMatrixFormatter.
Constructor Details
#initialize(options = {}) ⇒ PrettyMatrixFormatter
Returns a new instance of PrettyMatrixFormatter.
7 8 9 10 |
# File 'lib/bioinform/formatters/pretty_matrix_formatter.rb', line 7 def initialize( = {}) @with_name = .fetch(:with_name, true) @letters_as_rows = .fetch(:letters_as_rows, false) end |
Instance Attribute Details
#letters_as_rows ⇒ Object (readonly)
Returns the value of attribute letters_as_rows.
5 6 7 |
# File 'lib/bioinform/formatters/pretty_matrix_formatter.rb', line 5 def letters_as_rows @letters_as_rows end |
#with_name ⇒ Object (readonly)
Returns the value of attribute with_name.
5 6 7 |
# File 'lib/bioinform/formatters/pretty_matrix_formatter.rb', line 5 def with_name @with_name end |
Instance Method Details
#format(motif) ⇒ Object
28 29 30 31 32 |
# File 'lib/bioinform/formatters/pretty_matrix_formatter.rb', line 28 def format(motif) raise Error, "PM doesn't respond to #name. Use formatter with option `with_name: false`" if @with_name && !motif.respond_to?(:name) return MotifFormatter.new(with_name: @with_name, nucleotides_in: (@letters_as_rows ? :rows : :columns)).format(motif) if @letters_as_rows optional_name(motif) + header + matrix_string(motif) end |