Class: YARP::Pack::Format
- Inherits:
-
Object
- Object
- YARP::Pack::Format
- Defined in:
- lib/yarp/pack.rb,
ext/yarp/api_pack.c
Instance Attribute Summary collapse
-
#directives ⇒ Object
readonly
Returns the value of attribute directives.
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
Instance Method Summary collapse
- #describe ⇒ Object
-
#initialize(directives, encoding) ⇒ Format
constructor
A new instance of Format.
Constructor Details
#initialize(directives, encoding) ⇒ Format
Returns a new instance of Format.
165 166 167 168 |
# File 'lib/yarp/pack.rb', line 165 def initialize(directives, encoding) @directives = directives @encoding = encoding end |
Instance Attribute Details
#directives ⇒ Object (readonly)
Returns the value of attribute directives.
163 164 165 |
# File 'lib/yarp/pack.rb', line 163 def directives @directives end |
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
163 164 165 |
# File 'lib/yarp/pack.rb', line 163 def encoding @encoding end |
Instance Method Details
#describe ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/yarp/pack.rb', line 170 def describe source_width = directives.map { |d| d.source.inspect.length }.max directive_lines = directives.map do |directive| if directive.type == SPACE source = directive.source.inspect else source = directive.source end " #{source.ljust(source_width)} #{directive.describe}" end (['Directives:'] + directive_lines + ['Encoding:', " #{encoding}"]).join("\n") end |