Skip to content

FixedWidth Coercion #390

@endersonmaia

Description

@endersonmaia

It would be nice to have a coercion like FiexdWiththat you could inform parameters like :

  • width: Integer
  • alignment: {left, right}
  • padding : String

Example :

class Register
  include Virtua.model

  attribute :some_field, FixedWidth, width: 6, alignment: :right, padding: " "
end

my_register = Register:new()
my_register.some_field = "abc"

puts my_register.some_field
"   abc"

I tried to navigate through the classes to find where to make this via Custom Coercion, but couldn't come up with an simple implementation.

You someone could point me the direction, I can try to put some effort and code into this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions