!!!
%html{ :xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en" }
%head
%meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" }
%meta{ :name => "description", :content =>"How to easily read and write binary data in Ruby" }
%meta{ :keywords =>"ruby, binary, binary data, parse binary data, read binary data, write binary data, binary file, read binary file, write binary file" }
%title
Reading, writing and parsing binary data in Ruby
:javascript
var TINY={};function T$(i){return document.getElementById(i)}function T$$(e,p){return p.getElementsByTagName(e)}TINY.accordion=function(){function slider(n){this.n=n;this.a=[]}slider.prototype.init=function(t,e,m,o,k){var a=T$(t),i=s=0,n=a.childNodes,l=n.length;this.s=k||0;this.m=m||0;for(i;i0&&(f==-1||this.m||i==d)){c.d=-1;h.className='';su(c,-1)}}};function su(c){c.t=setInterval(function(){sl(c)},20)};function sl(c){var h=c.offsetHeight,d=c.d==1?c.m-h:h;c.style.height=h+(Math.ceil(d/5)*c.d)+'px';c.style.opacity=h/c.m;c.style.filter='alpha(opacity='+h*100/c.m+')';if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'}clearInterval(c.t)}};return{slider:slider}}();
var menu1, menu2, menu3, menu4, menu5, menu6, menu7;
var menu8, menu9, menu10, menu11, menu12, menu13, menu14, menu15;
function init_accordion() {
menu1 = new TINY.accordion.slider("menu1"); menu1.init("menu1","a",1,-1);
menu2 = new TINY.accordion.slider("menu2"); menu2.init("menu2","a",1,-1);
menu3 = new TINY.accordion.slider("menu3"); menu3.init("menu3","a",1,-1);
menu4 = new TINY.accordion.slider("menu4"); menu4.init("menu4","a",1,-1);
menu5 = new TINY.accordion.slider("menu5"); menu5.init("menu5","a",1,-1);
menu6 = new TINY.accordion.slider("menu6"); menu6.init("menu6","a",1,-1);
menu7 = new TINY.accordion.slider("menu7"); menu7.init("menu7","a",1,-1);
menu8 = new TINY.accordion.slider("menu8"); menu8.init("menu8","a",1,-1);
menu9 = new TINY.accordion.slider("menu9"); menu9.init("menu9","a",1,-1);
menu10 = new TINY.accordion.slider("menu10"); menu10.init("menu10","a",1,-1);
menu11 = new TINY.accordion.slider("menu11"); menu11.init("menu11","a",1,-1);
menu12 = new TINY.accordion.slider("menu12"); menu12.init("menu12","a",1,-1);
menu13 = new TINY.accordion.slider("menu13"); menu13.init("menu13","a",1,-1);
menu14 = new TINY.accordion.slider("menu14"); menu14.init("menu14","a",1,-1);
menu15 = new TINY.accordion.slider("menu15"); menu15.init("menu15","a",1,-1);
};
window.onload = init_accordion;
%style{:type => "text/css", :media => "screen"}
:plain
body {
margin:0; padding:0; border:0;
height:100%; max-height:100%;
overflow:hidden;
background-color:#FFF;
}
#left_frame {
position:absolute; overflow:hidden;
top:0; bottom:0; left:0;
width:240px; height:100%;
}
#main_frame {
position:fixed; overflow:auto;
top:0; right:0; bottom:0; left:240px;
}
* html body { /*IE6 hack*/
padding: 0 0 0 240px;
}
* html #main_frame { /*IE6 hack*/
height: 100%; width: 100%;
}
.menu_top_level {margin:5px;}
.menu_top_level ul {list-style:none; margin:0; padding:0;}
.menu_top_level li {margin-top:5px;}
.menu_top_level .acc-section {overflow:hidden;}
.menu_top_level .acc-content {width:100%; margin:0; padding:0; background:#FFF}
.menu_top_level li a {
display:block; cursor:pointer; text-decoration: none;
border:1px solid #9BC;
padding: 0;
font:bold 12px/2 Verdana, Arial, Helvetica;
}
.menu_top_level li a:link, .menu_top_level li a:visited { color: #131; background:#FFE;}
.menu_top_level li a:hover {background: #9C9; color:#FFE;}
.menu_top_level .level1 li a { padding-left: 15px; }
.menu_top_level .level2 li a { padding-left: 30px; }
.menu_top_level .level3 li a { padding-left: 45px; }
#main_content {
margin: 20px; padding-left: 3em;
width: 40em;
font-family: Georgia, Times;
}
#main_content h1 { margin-left: -1em;}
#main_content h2 { margin-left: -1em;}
#main_content pre {
margin-left: 2em; padding: 4px;
background-color: #EFF;
border: solid 1px #BDD;
}
#main_content .ruby .normal {}
#main_content .ruby .comment { color: #005; font-style: italic; }
#main_content .ruby .keyword { color: #A00; font-weight: bold; }
#main_content .ruby .method { color: #077; }
#main_content .ruby .class { color: #074; }
#main_content .ruby .module { color: #050; }
#main_content .ruby .punct { color: #447; font-weight: bold; }
#main_content .ruby .symbol { color: #099; }
#main_content .ruby .string { color: #944; background: #FFE; }
#main_content .ruby .char { color: #F07; }
#main_content .ruby .ident { color: #004; }
#main_content .ruby .constant { color: #07F; }
#main_content .ruby .regex { color: #B66; background: #FEF; }
#main_content .ruby .number { color: #F99; }
#main_content .ruby .attribute { color: #7BB; }
#main_content .ruby .global { color: #7FB; }
#main_content .ruby .expr { color: #227; }
#main_content .ruby .escape { color: #277; }
%script{:type => "text/javascript"}
:plain
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20958115-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
%body
#left_frame
.menu_top_level
%ul.level1#menu1
%li
%a{ :href => "#bindata" }
BinData
.acc-section
.acc-content
%ul.level2#menu2
%li
%a{ :href => "#what_is_it_for" }
What is it for?
.acc-section
.acc-content
%li
%a{ :href => "#license" }
License
.acc-section
.acc-content
%li
%a{ :href => "#donate" }
Donate
.acc-section
.acc-content
%li
%a{ :href => "#installation" }
Installation
.acc-section
.acc-content
%li
%a{ :href => "#overview" }
Overview
.acc-section
.acc-content
%li
%a{ :href => "#records" }
Records
.acc-section
.acc-content
%ul.level2#menu3
%li
%a{ :href => "#specifying_default_endian" }
Specifying default endian
.acc-section
.acc-content
%li
%a{ :href => "#dependencies_between_fields" }
Dependencies between fields
.acc-section
.acc-content
%li
%a{ :href => "#nested_records" }
Nested Records
.acc-section
.acc-content
%li
%a{ :href => "#optional_fields" }
Optional fields
.acc-section
.acc-content
%li
%a{ :href => "#primitive_types" }
Primitive Types
.acc-section
.acc-content
%ul.level2#menu4
%li
%a{ :href => "#numerics" }
Numerics
.acc-section
.acc-content
%ul.level3#menu5
%li
%a{ :href => "#byte_based_integers" }
Byte based integers
.acc-section
.acc-content
%li
%a{ :href => "#bit_based_integers" }
Bit based integers
.acc-section
.acc-content
%li
%a{ :href => "#floating_point_numbers" }
Floating point numbers
.acc-section
.acc-content
%li
%a{ :href => "#example" }
Example
.acc-section
.acc-content
%li
%a{ :href => "#strings" }
Strings
.acc-section
.acc-content
%ul.level3#menu6
%li
%a{ :href => "#fixed_sized_strings" }
Fixed Sized Strings
.acc-section
.acc-content
%li
%a{ :href => "#zero_terminated_strings" }
Zero Terminated Strings
.acc-section
.acc-content
%li
%a{ :href => "#user_defined_primitive_types" }
User-defined Primitive Types
.acc-section
.acc-content
%ul.level3#menu7
%li
%a{ :href => "#advanced_user_defined_primitive_types" }
Advanced Example
.acc-section
.acc-content
%li
%a{ :href => "#compound_types" }
Compound Types
.acc-section
.acc-content
%ul.level2#menu8
%li
%a{ :href => "#arrays" }
Arrays
.acc-section
.acc-content
%ul.level3#menu9
%li
%a{ :href => "#array_syntax" }
Array syntax
.acc-section
.acc-content
%li
%a{ :href => "#array_parameters" }
Array parameters
.acc-section
.acc-content
%li
%a{ :href => "#choices" }
Choices
.acc-section
.acc-content
%ul.level3#menu10
%li
%a{ :href => "#choice_syntax" }
Choice syntax
.acc-section
.acc-content
%li
%a{ :href => "#choice_parameters" }
Choice parameters
.acc-section
.acc-content
%li
%a{ :href => "#default_selection" }
Default Selection
.acc-section
.acc-content
%li
%a{ :href => "#common_operations" }
Common Operations
.acc-section
.acc-content
%ul.level2#menu11
%li
%a{ :href => "#reading_and_writing" }
Reading and writing
.acc-section
.acc-content
%li
%a{ :href => "#manipulating" }
Manipulating
.acc-section
.acc-content
%li
%a{ :href => "#inspecting" }
Inspecting
.acc-section
.acc-content
%li
%a{ :href => "#advanced_topics" }
Advanced Topics
.acc-section
.acc-content
%ul.level2#menu12
%li
%a{ :href => "#debugging" }
Debugging
.acc-section
.acc-content
%ul.level3#menu13
%li
%a{ :href => "#tracing" }
Tracing
.acc-section
.acc-content
%li
%a{ :href => "#rest" }
Rest
.acc-section
.acc-content
%li
%a{ :href => "#hidden_fields" }
Hidden fields
.acc-section
.acc-content
%li
%a{ :href => "#parameterizing_user_defined_types" }
Parameterizing Types
.acc-section
.acc-content
%ul.level3#menu14
%li
%a{ :href => "#mandatory_parameters" }
Mandatory Parameters
.acc-section
.acc-content
%li
%a{ :href => "#default_parameters" }
Default Parameters
.acc-section
.acc-content
%li
%a{ :href => "#extending_existing_types" }
Extending existing Types
.acc-section
.acc-content
%li
%a{ :href => "#dynamically_creating_types" }
Dynamically creating Types
.acc-section
.acc-content
%li
%a{ :href => "#skipping_over_unused_data" }
Skipping over unused data
.acc-section
.acc-content
%li
%a{ :href => "#determining_stream_length" }
Determining stream length
.acc-section
.acc-content
%li
%a{ :href => "#advanced_bitfields" }
Advanced Bitfields
.acc-section
.acc-content
%li
%a{ :href => "#faq" }
FAQ
.acc-section
.acc-content
%ul.level2#menu15
%li
%a{ :href => "#im_using_ruby_19_how_do_i_use_string_encodings_with_bindata" }
String encoding - Ruby 1.9
.acc-section
.acc-content
%li
%a{ :href => "#how_do_i_speed_up_initialization" }
Performance
.acc-section
.acc-content
%li
%a{ :href => "#how_do_i_model_this_complex_nested_format" }
Recursive declarations
.acc-section
.acc-content
%li
%a{ :href => "#alternatives" }
Alternatives
.acc-section
.acc-content
#main_frame
#main_content
:maruku
#{File.read("doc/manual.md")}